A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2005-September/347665.html below:

assign dict by value to list

assign dict by value to list assign dict by value to listTerry Reedy tjreedy at udel.edu
Wed Sep 7 01:43:18 EDT 2005
"Phill Atwood" <fakeaddress at nowhere.org> wrote in message 
news:WosTe.9302$vN.460573 at news20.bellglobal.com...
> def csv_it():
>     db = []  # the entire database of records
>     rec = {} # a single rec: a dictionary of field names and data pairs

Move this line

>     fields = [] # list of field names collected so far for current record
>     for line in open(inputfile):

to here

>         kword = getkeyword(line) # get keyword (or field name)
...
>                 # Now clear current record
>                 fields = []
>                 rec.clear()

and delete this

>                 dummylist = []

and I think you will have what you want (or close).
The initial fields = [] line could be moved also, I believe, without 
thoroughly reading your code.

Terry J. Reedy 




More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4