ideally what i would like is to be able to traverse each line of the
parsed file, and then refer to each of its fields by header name, so
that if the column order in the file changes my program will be
unaffected:
What you want is a DictReader.
For a quick example of me using that,
···
----------
aReader = csv.DictReader(open(inputFilename, 'r'), delimiter='\t')
yValues = {} # Will be a dictionary of lists (these are lists of y-values)
xValues = # List of x values (timestamps)
for row in aReader:
xValues.append(datetime.datetime(*(time.strptime(row['TimeStamp'],timeStampFormat)[0:6])))
for field in sorted(row,reverse=True): # Read from last to first in field list
if field=='TimeStamp': continue # Column of x-data
if not field in yValues.keys():
yValues[field] = [nt(row[field])] # Start list of the values in this column
else:
yValues[field].append(int(row[field])) # Add to list of values in this column
----------
Mike