Reputation: 966
db_path = "./db_file.csv"
db_read = open(db_path, "r")
for row in db_read:
g_tag = (row)[1]
My code is not accessing the second column as expected. Instead it is returning the second character of the 0th column. Don't get whats going on.
Upvotes: 0
Views: 70
Reputation: 966
Forgot to do this:
db_read = open(db_path, 'r')
db_reader = csv.reader(db_read)
Upvotes: 0
Reputation: 1367
Salah is right, although I'd advise against parsing a csv file directly:
In [63]: with open('output.csv', 'r') as f:
...: reader = csv.reader(f)
...: for row in reader:
...: print row
...:
['latitude', 'local_time', 'longitude', 'time']
['51.2997804', '20:01:14:334 11 08 2015 +0100 GMT+01:00', '1.070336', '1439319674334']
['51.2997889', '20:01:34:428 11 08 2015 +0100 GMT+01:00', '1.0703332', '1439319694428']
['51.2997794', '20:01:54:638 11 08 2015 +0100 GMT+01:00', '1.0703123', '1439319714638']
Upvotes: 1
Reputation: 504
you need to use the csv module to parse csv files intuitively, otherwise you can just use row.split(',')
to get values
Upvotes: 0