Why will this for loop not return one field from list rather than the list?
- by Dick Eshelman
import csv
"""sample row = 10/6/2010,73.42,74.43,72.9,74.15,2993500"""
filename_in = 'c:/python27/scripts/fiverows.csv'
reader = csv.reader(open(filename_in, "rb"), dialect="excel", delimiter="\t", quoting =csv.QUOTE_MINIMAL)
for row in reader:
for item in row:
print 'row = ',row
print 'item = ', item
When you run this script and print the row you get the sample row returned in [] as a list.
When you print the item you get the sample row as an unquoted string. Why do I not get each field ie, (10/6/2010), (73.42), etc. returned as an item? How do I return a single item?