# python###############将文件夹下所有csv文件转换成所有txt##################import pandas as pdimport os# 打开文件csv,转换一个文件def change_one(file_name):(shotname,extension) = os.path.splitext(file_name)data = pd.read_csv(file_path+file_name, encoding='utf-8')# write_path = file_path+'txt_file\\' # if not os.path.exists(write_path):# os.makedirs(write_path)with open(file_path+shotname+'.txt','a+', encoding='utf-8',) as f:for line in data.values:f.write((str(line[0])+'\t'+str(line[1])+'\n'))#批量化def change_all(file_path):listdir = os.listdir(file_path)for f in listdir:change_one(f)file_name = '地形数据.csv'file_path = 'E:\\James\\code\\data\\'change_all(file_path)
1500字范文,内容丰富有趣,写作好帮手!