I'm trying to create a function to read CSV files in python, but somehow I get a strange error.Is there any way to improve this?
defcsv_input(csv):
data = [ ]
f = open(csv, 'r')
reader=csv.reader(f)
For row in reader:
data.append(row)
return data
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "makes.py", line 70, in input_datas
data=csv.reader(f)
AttributeError: 'str' object has no attribute' reader'
I get this error.I don't know why it comes out.
python csv
The names of the csv
and the csv module
in the argument conflict.
reader=csv.reader(f)
may mean calling reader()
in the csv
module, but calling reader()
with csv
argument, so it gets 'str'object has no attribute'
.
© 2024 OneMinuteCode. All rights reserved.