help on Implementing a list of dicts with no data pattern

Dave Angel davea at davea.name
Wed May 8 20:05:15 EDT 2013


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



More information about the Python-list mailing list