List Contains NULL Byte, CSV DictReader
How can I remove NULL bytes using DictReader method? The following code produce error as Error: line contains NULL byte with open('excelfile.csv', 'r', encoding='ISO-8859-1') as f
Solution 1:
You can replace your NULL bytes by an empty string. Like this:
reader = csv.DictReader(x.replace('\0', '') for x in file)
Example:
with open('excelfile.csv', 'r', encoding="ISO-8859-1") as file:
reader = csv.DictReader(x.replace('\0', '') for x in file)
for row in reader:
frame = {'bank': row['BANK'], 'ifsc': row['IFSC'], 'branch': row['BRANCH'], 'address': row['ADDRESS'] }
framelist.append(frame)
Post a Comment for "List Contains NULL Byte, CSV DictReader"