Jan-07-2023, 09:13 AM
(Jan-07-2023, 12:10 AM)snippsat Wrote: Can show a way,so output is like in the image.
import pandas as pd with open("pd.txt") as f: result = [i.strip('================') for i in f] # Clean up s1 = result[:3] s1 = [i.strip().split() for i in s1] s2 = result[3:][1:-1] s2 = [i.strip().split() for i in s2] # To Pandas df1 = pd.DataFrame(s1) df1 = df1.rename(columns=df1.iloc[0]).drop(df1.index[0]) df2 = pd.DataFrame(s2) df2 = df2.rename(columns=df2.iloc[0]).drop(df2.index[0]) # To Excel writer = pd.ExcelWriter('out.xlsx', engine='openpyxl') df1.to_excel(writer, 'sheet', index=False) df2.to_excel(writer, 'sheet1', index=False) writer.save()
when i run it occur this error, do you know how to fix this
FutureWarning: save is not part of the public API, usage can give unexpected results and will be removed in a future version
writer.save()