I was trying to code a python program so that I can read a txt file that has jumbled up things like date, time, name and status in each line and I want to split all file's line and do something like shown below. I have also searched in Internet and I did not find it.
My txt file is:
12/30/20
4:48 PM
PY New
Refund
12/30/20
4:24 PM
Not Refund
Done
And I want that program to write something like this:
Date Time Name Status
12/30/20 4:48 PM PY New Refund
12/30/20 4:24 PM Not Refund Done
Here is my python code:
filename = "RawData.txt"
with open(filename, "r") as fin:
for line in fin:
while 3 > 0:
print(line.strip(""))
break
with open("ProcessedData.txt", "w") as fin:
#"newdata" is the variable that will store the data after splitting in 3 lines.
fin.write(newdata)