[Tutor] mapping header row to data rows in file

Sivaram Neelakantan nsivaram.net at gmail.com
Wed Jun 26 17:36:48 CEST 2013


I have a file with 100s of columns going thus

name age sex ....
AA   23  M ...
AB   26  M ....

while I can read the first row as

header = file.readline().split()

how do I get to map each col name in header to the subsequent data rows? As
in
name = AA
age = 23
sex = M

when processing the first data record and then refreshing it with the 2nd
data row after I process it in a loop?  Is the zip function, the way to go?

 sivaram
 -- 



More information about the Tutor mailing list