I have a CSV file with 5500 rows, When I run this script in the script console the output stops at row 1925… What would cause this ?
[code]import fileinput
inputFile=system.file.openFile(‘csv’)
values = ‘’
flag = 0
columns = ‘’
x = 0
if inputFile != None:
fileinput.close()
for lineIn in fileinput.input(inputFile):
flagTest=lineIn[:-(len(lineIn)-5)] #Extract first five characters of the line.
if flag==1:
columns='(' + lineIn + ')' #column list for query
flag=0 #Reset flag
if flag==2:
values+="('" + lineIn.replace('"','').replace(",","','") + "')," #add set of values. Strip away all double quotes,
# add single quotes to all values,
# wrap in parentheses,
# and pop a comma on the end.
# The comma prepares for the next set of values.
if flagTest =='#NAME': #Set flag according to '#" line delimiter
flag=1
elif flagTest == '#ROWS':
flag=2
elif flagTest == '#TYPE':
flag=0
#fileinput.close()
values=values[:-1] #Strip off last comma after all the values have been processed
query="INSERT INTO table " + columns + " VALUES "+ values
fileinput.close()
print query
#system.db.runUpdateQuery(query)[/code]