Sunday, 11 August 2013

Transefrring .CSV file to a list in Python

Transefrring .CSV file to a list in Python

I'm trying to get data from a CSV file to a list in Python. This is what I
have so far:
import csv
with open('RawEirgrid2.csv','rb') as csvfile:
M = csv.reader(csvfile, delimiter=',')
print(M[0])
I'm trying to print the first item in the list just confirm the code is
working (it's currently not). I get the following error:
TypeError: '_csv.reader' object is not subscriptable
In every example I look at it appears it should be subscriptable, so I'm
not sure whats going on.

No comments:

Post a Comment