关闭。这个问题不符合 Stack Overflow guidelines 。它目前不接受答案。
想改善这个问题吗?更新问题,以便堆栈溢出为 on-topic。
7年前关闭。
Improve this question
我正在寻找一个 python 库或任何将 .XLSX 文件转换为 .CSV 文件的帮助。
最佳答案
使用 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()
关于python - 使用python将XLSX正确转换为CSV,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20105118/