I have to copy data from a .dat file and paste it into excelfile format. Currently, i am reading line by line dat file and appending it to existing xlsx file.(I can write into new xlsx file but then i have to append headers and formatting of that file).
book = openpyxl.load_workbook(SIQFile)
sheet = book.active
with open(AFile,"r") as F1:
#line=F1.readlines()
line1=F1.readline()
cnt = 1
while line1:
#print("Line {}: {}".format(cnt, line1.strip()))
list1=line1.split("\t")
if cnt !=1:
sheet.append(list1)
line1 = F1.readline()
cnt += 1
print cnt
book.save(rootFolder+'.xlsx')
But it is taking to much time as it is reading line by line and then writing it to xlsx file. I can read all lines at a time using
line=F1.readlines()
But i can i write all lines at a time in xlsx file. In .dat file data seperated by tab