pandas小demo

原文链接: http://www.cnblogs.com/rise0111/p/11573466.html
# 将txt文件转换成excel文件
import pandas as pd 
import os
file_list = os.listdir('corpus')
for file in file_list:
    file_path = 'corpus/'+file
    data = pd.read_csv(file_path,encoding='utf-8',header=None)
    new_file = file.replace('txt','xlsx')
    data.to_excel(new_file,header=None)

转载于:https://www.cnblogs.com/rise0111/p/11573466.html

你可能感兴趣的:(pandas小demo)