Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!cs.uu.nl!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!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; 'lines,': 0.07; 'variables': 0.07; 'subject:help': 0.08; 'append': 0.09; 'clause': 0.09; 'repeated': 0.09; 'python': 0.11; 'before.': 0.16; 'combinations': 0.16; 'dict': 0.16; 'guys,': 0.16; 'iterating': 0.16; 'nesting': 0.16; 'rdbms': 0.16; 'received:74.208.4.195': 0.16; 'storing': 0.16; 'wrote:': 0.18; 'file,': 0.19; 'first.': 0.19; 'later': 0.20; 'select': 0.22; 'example': 0.22; 'header :User-Agent:1': 0.23; 'url:moin': 0.24; '(see': 0.26; 'post': 0.26; 'values': 0.27; 'header:In-Reply-To:1': 0.27; 'fixed': 0.29; 'subject:list': 0.30; "i'm": 0.30; 'code': 0.31; 'url:wiki': 0.31; 'keys': 0.31; 'with,': 0.31; 'lists': 0.32; 'text': 0.33; 'url:python': 0.33; 'problem': 0.35; 'subject:with': 0.35; 'version': 0.36; 'subject:data': 0.36; 'done': 0.36; 'doing': 0.36; 'url:org': 0.36; 'list': 0.37; 'list.': 0.37; 'to:addr :python-list': 0.38; 'pm,': 0.38; 'track': 0.38; 'sure': 0.39; 'to:addr:python.org': 0.39; 'read': 0.60; 'tell': 0.60; 'mentioned': 0.61; 'new': 0.61; "you're": 0.61; 'times': 0.62; 'different': 0.65; 'here': 0.66; 'received:74.208': 0.68; 'now:': 0.74; 'have.': 0.93 Date: Wed, 08 May 2013 20:05:15 -0400 From: Dave Angel 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: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:6F2xjXeC3zBRMXuW+7Mth4dcnHffUxKGxXPwjmkyhAW lUw2BCguhfnrepKddCBasSfzarjR8/nqCeyvTNuqtNY8IW+vPc xTMO0iDMgUDy7BRvNGHK4/oPWb90y1jFDdpcmEGa2VtXd9kvBz UW1Lgwj+KaDIIRC+n1SBTIY7aULwQixbGRoUCC+H8jUBYRuyQY M1D+MYuIbexXSL+fawwQ/U+h50rmZCDYAC3PQ1+cpRI1BYqoww AaMdzhj5+jtDfaGSgtGuIXb7agEqTluqakt/9nTwDNu9wMxzr8 uK8Z//90zBh9/uSnYcL2C9Ss03YMNgx0Ll95eAMTZvvMK4K7g= = X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list 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: 29 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1368057946 news.xs4all.nl 16009 [2001:888:2000:d::a6]:59849 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:44979 On 05/08/2013 07:47 PM, rlelis wrote: > Hi guys, > Please read this http://wiki.python.org/moin/GoogleGroupsPython. > 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 > If you want a response here, please post the code here. If it's over 50 lines, simplify it first. And be sure and tell us what version of Python and what other dependencies you might have. And what OS you're targeting. -- DaveA