python3
读文件
def csv_read(path):
data = []
with open(path,'r',encoding='utf-8-sig') as f:
reader = csv.reader(f,dialect='excel')
for row in reader:
data.append(row)
f.close()
return data
写文件
def csv_write(path,data):
with open(path,'a+',encoding='utf-8',newline='') as f:
f.write(data+"\n")
f.close()
return True
通配符路径下寻找文件
for root, dirs, files in os.walk('D:/file/test/20190819/test/'):
for file in files:
if file.find(".csv") != -1:
# print(file)
data = csv_read('D:/file/test/20190819/test/'+file)
for j in data:
newStr = "\t".join(j)
# print(newStr)
csv_write(outputPath+file, newStr)