寫成CSV檔/Xlsx檔
寫成CSV檔
import pandas as pd
#產出CSV檔
def OutputCSV():
Result ='C://A/B/C/SAMPLE.csv'
df_SAMPLE = pd.DataFrame.from_dict( SAMPLE_List )
df_SAMPLE.to_csv( Result , index=False )
print( '成功產出'+Result )
寫成Xlsx檔 - 寫入不同sheet
import pandas as pd
#產出excel檔
def OutputExcel():
Result_PATH = 'C://A/B/C/AAA.xlsx'
writer = pd.ExcelWriter( Result_PATH , engine='xlsxwriter')
#SHEET1
df_S1 = pd.DataFrame.from_dict( S1_List )
df_S1.to_excel(writer, sheet_name='SHEET1' ,index =False)
#SHEET2
df_S2 = pd.DataFrame.from_dict( S2_List )
df_S2.to_excel(writer , sheet_name='SHEET2' ,index =False)
writer .save()
print( '成功產出'+Result_PATH )
人生美好~別浪費腦容量記程式碼 :- )
作者:CYL
出處:http://dotblogs.com.tw/cylcode
資料來源都會特別註明,有興趣都可查詢原出處,本站皆經過整理才分享,如有轉載請顯示出處及作者,感謝。