Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #45037

Re: help on Implementing a list of dicts with no data pattern

Date 2013-05-09 10:50 -0400
From Dave Angel <davea@davea.name>
Subject Re: help on Implementing a list of dicts with no data pattern
References <c27c3eef-44f5-467c-b3a3-119263deb035@googlegroups.com> <fd60505e-3a05-41e3-aecc-c812a24f5077@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.1493.1368111061.3114.python-list@python.org> (permalink)

Show all headers | View raw


On 05/09/2013 10:33 AM, rlelis wrote:
> I apologize once again.
> Is my first post here and i'm getting used to the group as long as i get the feedback of my errors by you guys.
> I'm using Python 2.7.3 with no dependencies, i'm simply using the standard
> library.
> Here is the "big picture" of the scenario(i have added it in the pastebin link too)
>
> FILE OUTPUT DESIRED:
> aging:
> aging  |total         |age
> aging  |0             |100
> aging  |2             |115
> aging  |3             |1
> aging  |4             |10
>
> highway:
> highway       | lanes         |       state   |       limit(mph)
> highway       |       4       |       disable |       25
> highway       |       2       |       disable |       245
> highway       |       3       |       disable |       125
> highway       |       2       |       enable  |       255
> highway       |       3       |       disable |       212
> highway       |       8       |       disable |       78
>
> FILE INPUT EXCERPT EXAMPLE:
> aging 0 100
> aging 2 115
> aging 3 1
> highway 4 disable 25
> highway 2 disable 245
> highway 0 enable 125
>
> Meanwhile i have change the code a little bit and achieve a output closer to what i want:

You're still missing the file read code.  My earlier assumption that it 
was a simple readlines() was bogus, or the line:
    if "aging" in file-content:

would never work.

Perhaps you have something like:

infile = open("xxxx","r")
file_content = [line.split() for line in infile]

if you confirm it, I'll try to go through the code again, trying to make 
sense of it.



-- 
DaveA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

help on Implementing a list of dicts with no data pattern rlelis <ricardo.lelis3@gmail.com> - 2013-05-08 16:47 -0700
  Re: help on Implementing a list of dicts with no data pattern Dave Angel <davea@davea.name> - 2013-05-08 20:05 -0400
  Re: help on Implementing a list of dicts with no data pattern MRAB <python@mrabarnett.plus.com> - 2013-05-09 01:16 +0100
  Re: help on Implementing a list of dicts with no data pattern rlelis <ricardo.lelis3@gmail.com> - 2013-05-09 02:57 -0700
    Re: help on Implementing a list of dicts with no data pattern Dave Angel <davea@davea.name> - 2013-05-09 08:26 -0400
    Re: help on Implementing a list of dicts with no data pattern Neil Cerutti <neilc@norwich.edu> - 2013-05-09 13:08 +0000
  Re: help on Implementing a list of dicts with no data pattern rlelis <ricardo.lelis3@gmail.com> - 2013-05-09 07:33 -0700
    Re: help on Implementing a list of dicts with no data pattern Dave Angel <davea@davea.name> - 2013-05-09 10:50 -0400
  Re: help on Implementing a list of dicts with no data pattern rlelis <ricardo.lelis3@gmail.com> - 2013-05-09 09:14 -0700
    Re: help on Implementing a list of dicts with no data pattern Dave Angel <davea@davea.name> - 2013-05-09 14:19 -0400
      Re: help on Implementing a list of dicts with no data pattern rlelis <ricardo.lelis3@gmail.com> - 2013-05-09 14:22 -0700
        Re: help on Implementing a list of dicts with no data pattern Dave Angel <davea@davea.name> - 2013-05-09 18:32 -0400
          Re: help on Implementing a list of dicts with no data pattern Neil Cerutti <neilc@norwich.edu> - 2013-05-10 12:54 +0000

csiph-web