Reading .csv Through Dictreader
I'm just trying to read a .csv using the first row as keys for the dictionary, with no success. My file has two lines (test), items being delimited by tabs. subjectID logID log
Solution 1:
You have for row in spamreader
outside the with
block in your actual code:
withopen(file_path, 'rb') as csvfile:
spamreader = csv.DictReader(csvfile, delimiter='\t')
print spamreader
for row in spamreader: # your codeprint row
Once you leave the with
block the file is closed so trying to read from the file object fails.
Post a Comment for "Reading .csv Through Dictreader"