The problem with remove the minus 1 below is that the first if statement will never be true because k will never equal the len(data).
was:
for i in range(len(head_search_val)):
found=0
for k in range(len(data)):
if k==len(data)-1 and found==0:
raise Exception('Could not find: ' + head_search_val[i])
warnings.warn('Could not find: ' + head_search_val[i])
head_results.append(['header not found'])
if len(data[k])<2:
continue
if head_search_val[i]==data[k][0]:
head_results.append(data[k][1:return_cols+1])
found=1
is:
for i in range(len(head_search_val)):
found=0
for k in range(len(data)):
if k==len(data) and found==0:
raise Exception('Could not find: ' + head_search_val[i])
warnings.warn('Could not find: ' + head_search_val[i])
head_results.append(['header not found'])
if len(data[k])<2:
continue
if head_search_val[i]==data[k][0]:
head_results.append(data[k][1:return_cols+1])
found=1
The problem with remove the minus 1 below is that the first if statement will never be true because k will never equal the len(data).
was: for i in range(len(head_search_val)): found=0 for k in range(len(data)): if k==len(data)-1 and found==0:
raise Exception('Could not find: ' + head_search_val[i])
is: for i in range(len(head_search_val)): found=0 for k in range(len(data)): if k==len(data) and found==0:
raise Exception('Could not find: ' + head_search_val[i])