Is there possible to read a text file, and write it into excel in the same file, but a different sheet? I have no idea, need help.
I have a text file that looks like this:
Timedate userID name
20221201 test hello
===================
Timedate userID name
20221202 tes1 hello
===================
How to split after ==== to a new separate excel sheet
sheet1:
Timedate userID name
20221201 test hello
sheet2:
Timedate userID name
20221202 tes1 hello
my python code:
import openpyxl, string
from openpyxl.utils import get_column_letter
from openpyxl.styles import Font
f = open('test.txt', 'r+') # open text
excel = openpyxl.Workbook()
sheet = excel.worksheets
line = f.readline(); # read text
count =0
while line:
list123 = line.split() # convert
if "Timedate" in list123:
count+=1
if count < 2:
print(list123)
else:
print()
print(list123)
else:
print(list123)
line = f.readline() # read next line
excel.save("test"+'.xlsx')