I have to put some numerical data, which I received in text file into an Excel file (no, Pandas won't work, because of the way that data is written in the file) and for some reason, it just won't work it just won't work. My latest attempt to get it done is below. I also tried with openpyxl with no success.
wb = w.Workbook('D:\\IJS\\JEFF444.xlsx')
ws = wb.add_worksheet()
with open(trimmed_data, 'r') as file:
lines = file.readlines()
row = 8
for index in range(len(lines)):
if len(lines[index].split()) != 0:
lst = lines[index].split()
print(lst)
if lst[-1][-3:] == '444':
print(lst[3].split('/')[0])
ws.write(f'B{row}', lst[3].split('/')[0])
ws.write(f'E{row}', float(lines[index + 2].split()[1]))
ws.write(f'F{row}', float(lines[index + 2].split()[1]) * float(lines[index + 2].split()[2]))
ws.write(f'J{row}', float(lines[index + 5].split()[1]))
ws.write(f'K{row}', float(lines[index + 5].split()[1]) * float(lines[index + 5].split()[2]))
ws.write(f'O{row}', float(lines[index + 8].split()[1]))
ws.write(f'P{row}', float(lines[index + 8].split()[1]) * float(lines[index + 8].split()[2]))
ws.write(f'T{row}', float(lines[index + 11].split()[1]))
ws.write(f'U{row}', float(lines[index + 11].split()[1]) * float(lines[index + 11].split()[2]))
row += 1
file.close()
wb.close()
dfsimply dodf.to_excel()