# -*- coding: UTF-8 -*- import os import pandas as pd if __name__ == '__main__': # 两层目录 dir_path = 'excelfilepath' path = os.listdir(dir_path) for pp in path: temp_path = dir_path + '/' + pp for p in os.listdir(temp_path): temp_t_path = temp_path + '/' + p # xlsx -> csv temp_c_path = temp_t_path.replace("excel", 'csv').replace("xlsx", 'csv') data = pd.read_excel(temp_t_path, p.split(".")[0], index_col=0) # *** data.to_csv(temp_c_path, encoding='gbk') print(temp_t_path, '->', temp_c_path)
python excel文件转csv文件
最新推荐文章于 2024-05-30 11:43:13 发布