I'm trying to catch a Null Byte Exception in the last line of a CSV file:
def Catch(csv_filename):
with open(csv_filename,'r+') as File:
File_reader = csv.reader(File,delimiter="\t",dialect='excel-tab')
a = []
for row in File_reader:
try:
a.append(row)
except csv.Error:
return "Error"
Catch("/../DataLogger.csv")
but an _csv.Error is raised:
Traceback (most recent call last):
File "/../test.py", line 21, in <module>
Catch("/../DataLogger.csv")
File "/../test.py", line 13, in Catch
for row in File_reader:
_csv.Error: line contains NULL byte
I don't get why the exception is not catched with the function. I'm using python 3.4