Hi and thanks for reading.
I have a problem with a for loop in python. I'm trying to read my .txt file line by line and importing each line in excel using worksheet.write_row. I have tried many other ways to get this done but being pretty new to all of this, this one has been the easiest for me to understand.
It worked selecting just one line from the file so I'm pretty sure that something is wrong with the "for" loop I have written.
I have tried out all different kinds of editing the loop I can think of but nothing worked. I also researched the web but couldn't find any solutions which I could identity. So any help would be greatly appreciated.
import xlsxwriter
workbook = xlsxwriter.Workbook('pythonlinetest.xlsx') #create file
worksheet = workbook.add_worksheet() #create worksheet
data = open('160919-001 14cts c133_vi.txt','r') #loaddata
#count lines
linelist = data.readlines()
count = len(linelist)
print count #check lines
#make each line and print in excel
for n in range (0, len(linelist))
line = linelist[n]
splitline = line.split("\t")
worksheet.write_row(row, 0, splitline)
row += 1
>>>> Error: File "<ipython-input-4-abc8f489522d>", line 2
for n in range (0, len(linelist))
^
SyntaxError: invalid syntax
#close workbook
workbook.close()
Thanks a lot!