Python自编工具函数

import pandas as pd

def xlsx_to_csv(filepath, chinese=False):
    '''将excel xlsx文件转化为csv文件
    '''
    fileName = filepath.rsplit(".", 1)[0]
    outName = fileName + '.csv'
    file = pd.read_excel(filepath)
    print(file.head())
    if chinese:
        file.to_csv(outName, encoding='utf_8_sig', index=False)
    else:
        file.to_csv(outName, index=False)
posted @ 2021-07-10 20:22  illmatic  阅读(43)  评论(0编辑  收藏  举报