Hi,
I'm getting this error when reading from a csv file: "Runtime Error!
line contains NULL byte".
Any idea about the root cause of this error?
If it helps, here's the part of my code where I'm reading the csv file.
def processFile():
global DATA # - Input file
global admin_id # - Comma separated list of admin IDs
global vf # - Verified list
global nf # - Non-verified list
global remainingAdmins # - Higher level admin IDs contained in the file,
# but not specified in the admin_id list that was used to generate input file
global counter # - Counter indicating row number
counter = 1
fieldCounter = 0DATA = open(optDict.get('--DATA'), 'r')
vf = []
nf = []
remainingAdmins = ''
country = ''for i in range(5):
vf.append('')
nf.append('')oldline = None
currInd = 0
prevInd = -1try:
reader = csv.reader(DATA)
for row in reader:#counter = 1 --> first line in the reader
# row[0] = $A$1 cell - the comma separated list of Admin Area IDs
if counter == 1:
admin_id = row[0][row[0].index(':') +1:]if counter >=3:
if len(row) == 13:
currInd = 0
flag = Truewhile flag:
if row[currInd] == '':
currInd += 2
else:
flag = Falseif currInd == 0:
country = row[currInd]if currInd <= prevInd:
fieldCounter += processFC(oldline, prevInd)
else:
if oldline != None:
fieldCounter += validateLine(oldline)
remainingAdmins += oldline[prevInd+1] + ','prevInd = currInd
oldline = rowelse:
log(["\n[Line# %d]: Invalid Record Syntax (Row Length expected 13 but was %d)\t" %(counter, len(row))])
log(["Row: %s\n" %row])
fieldCounter += 1counter = counter +1
# process the last line
fieldCounter += processFC(oldline, prevInd)
remainingAdmins = remainingAdmins[:-1]stmt = "\nTotal number of invalid field values: %d\n" %fieldCounter
log([stmt])
print stmtfinally:
if fieldCounter == 0:
stmt = "\nDATA Syntax Valid\n"
print stmt
log([stmt])
else:
raise Exception("Data file contains incorrect values")
Thanks,