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 = 0
DATA = open(optDict.get('--DATA'), 'r')
vf =  nf =  remainingAdmins = '' country = ''
for i in range(5): vf.append('') nf.append('')
oldline = None currInd = 0 prevInd = -1
try: reader = csv.reader(DATA) for row in reader:
#counter = 1 --> first line in the reader # row = $A$1 cell - the comma separated list of Admin Area IDs if counter == 1: admin_id = row[row.index(':') +1:]
if counter >=3: if len(row) == 13: currInd = 0 flag = True
while flag: if row[currInd] == '': currInd += 2 else: flag = False
Ok, I got it and thought I'd post the solution. Simply yet caused me grief... Used file was saved in a .xls format instead of a .csv Didn't catch this because the file name itself had the .csv extension while the type was still .xls