django - How to read a csv file script Python? -
how read csv file script python?
import csv open('some.csv', 'rb') f: reader = csv.reader(f) row in reader: print row
gives error
python2 test.py traceback (most recent call last): file "test.py", line 1, in <module> import csv file "/home/miruss/virtualbox/csv.py", line 4, in <module> f = open(sys.argv[1], 'rt') indexerror: list index out of range
the reason error not understand.
your error comes "sys.argv[1]".
you meant execute code against file name.
python2 test.py filename.csv
Comments
Post a Comment