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

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!newsfeed.eweka.nl!eweka.nl!feeder3.eweka.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <davea@davea.name>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.021
X-Spam-Evidence '*H*': 0.96; '*S*': 0.00; 'example:': 0.03; 'output': 0.05; 'subject:help': 0.08; 'guys.': 0.09; 'line:': 0.09; 'python': 0.11; '2.7.3': 0.16; '255': 0.16; 'desired:': 0.16; 'excerpt': 0.16; 'meanwhile': 0.16; 'received:74.208.4.195': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'bit': 0.19; 'trying': 0.19; 'input': 0.22; 'header:User-Agent:1': 0.23; 'earlier': 0.24; 'post': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'errors': 0.30; 'subject:list': 0.30; "i'm": 0.30; 'work.': 0.31; 'code': 0.31; 'getting': 0.31; 'closer': 0.31; 'disable': 0.31; 'file': 0.32; 'sense': 0.34; 'subject:with': 0.35; 'something': 0.35; 'highway': 0.36; 'library.': 0.36; 'subject:data': 0.36; "i'll": 0.36; 'feedback': 0.38; 'skip:[ 10': 0.38; 'to:addr:python-list': 0.38; 'little': 0.38; 'to:addr:python.org': 0.39; 'read': 0.60; 'simply': 0.61; 'simple': 0.61; "you're": 0.61; 'first': 0.61; 'confirm': 0.64; 'here': 0.66; 'received:74.208': 0.68; '100': 0.79; '"big': 0.84; 'want:': 0.84; '212': 0.91; 'aging': 0.91
Date Thu, 09 May 2013 10:50:45 -0400
From Dave Angel <davea@davea.name>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5
MIME-Version 1.0
To python-list@python.org
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>
In-Reply-To <fd60505e-3a05-41e3-aecc-c812a24f5077@googlegroups.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Provags-ID V02:K0:QcAOorFi3+dNXLluqwrxb1AZC7vu+uDun8RST9nYykB cdx9RqGR7QhVQHEBqVNQ0x/6O0RAR2Md+Zk/mWHdvdU/w0ZHcp +jz39npnuZQuGLZ0BuWmC2VzjC09K/2WSZhVz99iMgvf5SwdMu 1ch4apS/CwTpLP8FI6D7e8qC1ezxeu59dwZJVXLpE7PSLULNgM 9rwmLCwLlIgUv73GYrQnuPQuT9gL50BDWxnxnghGweCxgpKbuP j2UMBuhOVpoeOfqZuacVsABq+MpWjolszTpek1c40yObeM5/IA N4oHsTFdSSPhp40Dg5x9GAzaDhGn5fKIssuF9PISqnIlPQ69Q= =
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1493.1368111061.3114.python-list@python.org> (permalink)
Lines 52
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1368111061 news.xs4all.nl 15880 [2001:888:2000:d::a6]:46586
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:45037

Show key headers only | 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