怎么用python做excel里的数据清洗

如题所述

解答如下:
首先打开txt文件,使用open(txtname),进行一行一行的读;
如果需要的话,对每行的数据进行解析;
导入xlrd,xlwt进行excel读写;
大致代码如下:
import
xlrd,xlwttxtname=r"c:\value.txt"workbook
=
xlwt.workbook(encoding
=
'ascii')worksheet
=
workbook.add_sheet('sheet1')fp=open(txtname)for
linea
in
fp.readlines():
worksheet.write(0,
0,
label
=
linea)workbook.save('excel_workbook.xls')fp.close()
温馨提示:答案为网友推荐,仅供参考
相似回答