Excel: xlsx 与 csv 格式的相互转换

import pandas as pd


def xlsx_to_csv_pd():
    """
    xlsx 转 csv
    :return:
    """
    data_xls = pd.read_excel('2018.12.xlsx', index_col=0)
    data_xls.to_csv('2018.12.csv', encoding='utf-8')

def csv_to_xlsx_pd():
    """
    csv 转 xlsx
    :return:
    """
    csv = pd.read_csv('2019.01.csv', encoding='utf-8')
    csv.to_excel('1.xlsx', sheet_name='data')


if __name__ == '__main__':
    xlsx_to_csv_pd()
    csv_to_xlsx_pd()

点赞

发表评论

电子邮件地址不会被公开。必填项已用 * 标注