assign dict by value to list
Terry 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