I couldn't understand while file is not considered by the interpreter
csv_data = csv.reader(file('D:\\Eclipse_Python\\Python\\com\\praveen\\pandas\\iplStats.csv'))
for row in csv_data:
print(row)
cur.execute('PREPARE stmt FROM INSERT INTO praveendb.iplstats (Wins,Losses,Year,Loss,Team) VALUES(?,?,?,?,?)', row)
ERROR:
Traceback (most recent call last):
File "D:\Eclipse_Python\Python\pandasLibDataFrame.py", line 28, in <module>
csv_data = csv.reader(file('D:\\Eclipse_Python\\Python\\pandas\\iplStats.csv'))
NameError: name 'file' is not defined
I assume you are suing Python 3. If you are using Python 3. File()
is not availabe instead use open()
import csv
with open('yourfile.csv') as csv_file:
do you code
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.