Nov-19-2022, 08:23 AM
(Nov-09-2022, 03:25 PM)deanhystad Wrote:(Nov-09-2022, 07:36 AM)jacklee26 Wrote: i have one more question what if my first second row is =====, how to able to implement, like this:This is why you don't want to use a solution where you assume certain cells will have certain values. My example doesn't care if you add columns or a row of "====" into the mix. It will pass the "====" through as text. If you don't want that in the spreadsheet, skip it.
[inline]
atettime Tput Tput2
====== ===== ========
20221018.165317.401555 0.000545 0.000545
20221018.165327.401723 0.001422 0.000545
[/inline]
i run it occur error:
ValueError: could not convert string to float: '===='
with open(src, "r") as src: # First line is column headings line = next(src).split() sheet.append(line) # Next line is thrown away next(src)
HI deanhystad,
why I use the code
import pandas as pd please refer the attached picture with open("result.txt", "r") as file: column_names = next(file).split() df = pd.read_csv(file, sep=" ", names=column_names) df.to_excel("test.xlsx", index=False)The datetime, or column did not write into excel file
For example, file is
datettime Tput RbNum MCS PdschBler nonWPdschBler
20221108.181509.814817 0.000091 2.5 9.0 0.0 25.0
20221108.181519.814948 0.000131 1.9 9.0 0.0 50.0
But in excel write like this
datettime Tput RbNum MCS PdschBler nonWPdschBler
0.000091 2.5 9.0 0.0 25.0
0.000131 1.9 9.0 0.0 50.0