[英]Python, file corruoption when converting .csv to .xlsx, without xlsxwriter.workbook module
I'm trying to convert a .csv file to a .xlsx file without using the xlsxwriter.workbook module. 我正在尝试不使用xlsxwriter.workbook模块将.csv文件转换为.xlsx文件。 The following code changes the format however when I try to open the file, I get prompted with "file format or file extension is not valid. Verify that the file has not been corrupted".
下面的代码更改了格式,但是当我尝试打开文件时,系统提示“文件格式或文件扩展名无效。请验证文件未损坏”。 Thanks
谢谢
import os
import tkSimpleDialog
from tkFileDialog import askopenfilename
my_file = askopenfilename()
newname = my_file.replace('.csv', '.xlsx')
output = os.rename(my_file, newname)
I don't think you can convert csv file into xlsx file without using another module. 我认为您可以在不使用其他模块的情况下将csv文件转换为xlsx文件。 I think your script only try to change the filename and do nothing to the content of the file.
我认为您的脚本仅尝试更改文件名,而对文件的内容不做任何事情。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.