import pandas as pd
import os
path=os.path.abspath('.')
file_path=os.path.join(path,'data/202112combineg/csvtransxlsx')
file_path1=os.path.join(path,'data/202112combineg\csvexample')
print(path)
print(file_path)
print(file_path)
source_csv=[]
for root,path,filename in os.walk(file_path1):
for file in filename:
source_csv.append(file)
print(source_csv)
for i in range(len(source_csv)):
data=pd.read_csv(file_path1+"/"+source_csv[i],encoding='utf-8',dtype=str)
data.to_excel(file_path+"/"+source_csv[i]+".xlsx")
print("Done!")
同一文件夹下所有CSV文件转化为excel文件
最新推荐文章于 2024-07-24 17:39:10 发布