[Tutor] Pouring a list into a dictionary
Erik Price
erikprice at mac.com
Thu Sep 4 23:09:58 EDT 2003
On Thursday, September 4, 2003, at 07:54 PM, Allen Schmidt wrote:
> I have a file that I parse out to lists.
> The first line contains the column headers.
> The rest of the lines contain the rows of data elements.
>
> I need to loop through the each row, grab each column name from the
> first
> line
> and would like to use each one as the key in a dictionary.
>
> Then for each subsequent row, grab each data element and use the
> dictionary key for the correct placement as that key's value.
>
> Make sense?? Kinda hard to explain.
>
> Any gentle nudges in the right direction would be greatly appreciated.
I'm not sure if it does what you're referring to, but if your data
records file is in CSV format then perhaps the csv module (new as of
2.3) is of some use to you.
Erik
More information about the Tutor
mailing list