The title bar does not use tabs.
When I recreate your data without tabs, the line returned by the csv module contains only one (long) key. If I recreate it using real tabs, I get:
>>> source_file = open('out.csv', 'rb') >>> reader = csv.DictReader(source_file, delimiter = '\t') >>> line = reader.next() >>> len(line) 37 >>> line.keys() ['Id', '..Easting', '.NE_Err', 'uSt', 'SeiMoment', 'MaxDispla', 'tSt', 'Ns', 'Nt', 'Nu', '.Northing', '.DD_Err', '...Energy', '....uMag', 'V2.0..', 'DyStressD', 'SRC', 'PeakAccPa', '.SourceRo', '........Time', '.EE_Err', 'T', 'Velocity', 'PeakVelPa', 'AspRadius', '...Depth', 'PSt', '....tMag', '.MomMag', 'AppStress', '...Es/Ep', '.ED_Err', 'Event', '.ND_Err', 'Conf', '.StaticSD', '.NN_Err'] >>> line['........Time'] 'ND' >>> line['.Northing'] '746.45'
Note that values ββdo not require deletion; the module will take care of extraneous spaces for you.
You can read your header separately, clear it, and then process the rest of the data with the csv module:
source_file = open(NNSRC, 'rb') header = source_file.readline() source_file.seek(len(header)) # reset read buffer headers = [h.strip('.') for h in header.split()] headers = ['Date'] + headers[2:] # Replace ['SRC', 'V2.0'] with a Date field instead for line in csv.DictReader(source_file, fieldnames=headers, delimiter = '\t'): # process line
The code above reads the header line separately, splits it, and removes the extra ones . periods to execute more efficient column columns, and then sets the file for DictReader by DictReader read buffer (side is the effect of calling .seek() ).