I keep getting a �??list index out of range�?� error message when doing this.
How many fields are there in the line? If you only have 10, lineList[36] will raise an out of range error.Here's another shot at this:
# skip 5 rows
skipRows = 5
for n in range(skipRows + 1):
line = inFile.readline()
row = skipRows + 1
# read and clean up data
while line:
print 'Row', row, 'line info=', line[:72]
# clean line and split into list
lineList = [f.strip().replace("/","_") for f in line.split(',')]
print 'line info =', lineList
latidx,lonidx = 36, 37 # lat and long are in field 36 and 37
if len(lineList) > lonidx:
raise Exception, "line {0} too short".format(row)
for k in latidx, lonidx:
if lineList == "":
lineList = 0
outFile.write(','.join(newList) + "\n")
line = inFile.readline()
row += 1