使用pandas实现csv/excel sheet互相转换的方法
1. xlsx to csv:
import pandas as pd def xlsx_to_csv_pd(): data_xls = pd.read_excel('1.xlsx', index_col=0) data_xls.to_csv('1.csv', encoding='utf-8') if __name__ == '__main__': xlsx_to_csv_pd()
2. csv to xlsx:
import pandas as pd def csv_to_xlsx_pd(): csv = pd.read_csv('1.csv', encoding='utf-8') csv.to_excel('1.xlsx', sheet_name='data') if __name__ == '__main__': csv_to_xlsx_pd()
相关推荐
wangquannuaa 2020-10-15
jzlixiao 2020-05-15
QianYanDai 2020-05-07
三石 2020-10-30
roamer 2020-10-29
三石 2020-10-29
wangquannuaa 2020-09-29
jzlixiao 2020-09-15
wangquannuaa 2020-08-30
三石 2020-08-23
逍遥友 2020-08-21
jzlixiao 2020-08-18
wangquannuaa 2020-08-17
QianYanDai 2020-08-16
cjsyrwt 2020-08-14
jzlixiao 2020-07-29
xirongxudlut 2020-07-20
mmmjyjy 2020-07-16
QianYanDai 2020-07-05