Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'variables': 0.07; 'subject:help': 0.08; 'append': 0.09; 'clause': 0.09; 'repeated': 0.09; 'before.': 0.16; 'combinations': 0.16; 'dict': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'guys,': 0.16; 'iterating': 0.16; 'iteration': 0.16; 'loop.': 0.16; 'message- id:@mrabarnett.plus.com': 0.16; 'nesting': 0.16; 'rdbms': 0.16; 'storing': 0.16; 'wrote:': 0.18; 'file,': 0.19; 'later': 0.20; 'meant': 0.20; 'select': 0.22; 'example': 0.22; 'creating': 0.23; 'header:User-Agent:1': 0.23; '(see': 0.26; 'values': 0.27; 'header :In-Reply-To:1': 0.27; 'fixed': 0.29; 'subject:list': 0.30; "i'm": 0.30; 'keys': 0.31; 'with,': 0.31; 'lists': 0.32; 'text': 0.33; 'problem': 0.35; 'subject:with': 0.35; 'subject:data': 0.36; 'done': 0.36; 'doing': 0.36; 'list': 0.37; 'list.': 0.37; 'to:addr :python-list': 0.38; 'track': 0.38; 'to:addr:python.org': 0.39; 'mentioned': 0.61; 'new': 0.61; "you're": 0.61; 'times': 0.62; 'different': 0.65; 'here': 0.66; 'header:Reply-To:1': 0.67; 'reply-to:no real name:2**0': 0.71; 'now:': 0.74; "'for'": 0.84; 'dict,': 0.84; 'reply-to:addr:python.org': 0.84 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.1 cv=TZ6v63gh c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=7AxPfEIvyrUA:10 a=d4ofnwa7K_AA:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=8nJEP1OIZ-IA:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=LQN-9AEzoIEA:10 a=fGO4tVQLAAAA:8 a=FpKWcMIw7PkGeALzJXgA:9 a=wPNLvfGTeEIA:10 X-AUTH: mrabarnett:2500 Date: Thu, 09 May 2013 01:16:10 +0100 From: MRAB User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130328 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: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: python-list@python.org List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 24 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1368058576 news.xs4all.nl 16012 [2001:888:2000:d::a6]:42218 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:44983 On 09/05/2013 00:47, rlelis wrote: > Hi guys, > > I'm working on this long file, where i have to keep reading and > storing different excerpts of text (data) in different variables (list). > > Once done that i want to store in dicts the data i got from the lists mentioned before. I want them on a list of dicts for later RDBMs purpose's. > > The data i'm working with, don't have fixed pattern (see example bellow), so what i'm doing is for each row, i want to store combinations of word/value (Key-value) to keep track of all the data. > > My problem is that once i'm iterating over the list (original one a.k.a file_content in the link), then i'm nesting several if clause to match > the keys i want. Done that i select the keys i want to give them values and lastly i append that dict into a new list. The problem here is that i end up always with the last line repeated several times for each row it found's. > > Please take a look on what i have now: > http://pastebin.com/A9eka7p9 > You're creating a dict for highway_dict and a dict for aging_dict, and then using those dicts for every iteration of the 'for' loop. You're also appending both of the dicts onto the 'queue_row' list for every iteration of the 'for' loop. I think that what you meant to do was, for each match, to create a dict, populate it, and then append it to the list.