geo*_*eek 37 python csv excel python-2.7
我正在寻找一个python库或任何帮助将.XLSX文件转换为.CSV文件.
Hem*_*ant 55
使用该xlrd模块阅读您的Excel ,然后您可以使用该csv模块创建自己的csv.
在命令行中安装xlrd模块:
pip install xlrd
Python脚本:
import xlrd
import csv
def csv_from_excel():
wb = xlrd.open_workbook('excel.xlsx')
sh = wb.sheet_by_name('Sheet1')
your_csv_file = open('your_csv_file.csv', 'w')
wr = csv.writer(your_csv_file, quoting=csv.QUOTE_ALL)
for rownum in range(sh.nrows):
wr.writerow(sh.row_values(rownum))
your_csv_file.close()
# runs the csv_from_excel function:
csv_from_excel()
Run Code Online (Sandbox Code Playgroud)