I tried to print some records off "the file" in csv format, but it keeps showing the error in Title. Yes i tried to change encoding to utf8, utf-16, as well as utf-16-le using notepad++. it still doesn't work. Please help :c
This is the input code:
import csv
f=open("thefile.csv", 'r', encoding="ansi")
reader=csv.reader(f)
covaxin=0
covishield=0
c1="Covaxin"
c2="Covishield"
a="41 - 60 years"
for row in reader:
if (row[3]==a):
for bro in reader:
if (bro[4]==c1):
covaxin+=1
print("Covaxin: ", covaxin)
elif (bro[4]==c2):
covishield+=1
print("Covishield:", covishield)
else:
print("error")
f.close()
and this is the output:
Traceback (most recent call last):
File "C:\Users\admin\Desktop\Reader Program.py", line 13, in <module>
for row in reader:
_csv.Error: line contains NUL