Reputation: 1
I'm trying to read a CSV file into python and I looked at different tutorials for it.
Input:
import csv
with open('test.csv', 'r') as csvdatei:
csv_reader=csv.reader('test.csv')
for line in csv_reader:
print(line)
Output:
['t']
['e']
['s']
['t']
['.']
['c']
['s']
['v']
Why does this not work? Why does it give me the split up file name as output?
I use python 3.7.3 on Spyder.
Upvotes: 0
Views: 43
Reputation: 39354
I think you meant to give csv
the contents of the file and not the filename:
import csv
with open('test.csv', 'r') as csvdatei:
csv_reader = csv.reader(csvdatei)
for line in csv_reader:
print(line)
Upvotes: 1