python保存为xlsb_如何使用Python将csv文件转换为xlsb?
我想将csv文件转换为xlsb.我使用了这个
Convert XLS to CSV on command line的第二个答案,这是下面的代码:
if WScript.Arguments.Count < 2 Then
WScript.Echo "Please specify the source and the destination files. Usage: ExcelToCsv "
Wscript.Quit
End If
csv_format = 6
Set objFSO = CreateObject("Scripting.FileSystemObject")
src_file = objFSO.GetAbsolutePathName(Wscript.Arguments.Item(0))
dest_file = objFSO.GetAbsolutePathName(WScript.Arguments.Item(1))
Dim oExcel
Set oExcel = CreateObject("Excel.Application")
Dim oBook
Set oBook = oExcel.Workbooks.Open(src_file)
oBook.SaveAs dest_file, csv_format
oBook.Close False
oExcel.Quit
我的代码如下:
import subprocess
subprocess.call("cscript CsvToExcel.vbs data.csv data.xlsb",
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False) # Supress any messages
问题是我找不到正确的值作为xlsb格式.我发现这个XlFileFormat Enumeration (Excel)有可用的值,但我不确定哪一个是我需要的.
有用提示:如果有人尝试转换第一行中第一项的csv是ID,则会发生错误.将ID更改为id,它会没问题,更多信息SYLK: File format is not valid.
总结
以上是生活随笔为你收集整理的python保存为xlsb_如何使用Python将csv文件转换为xlsb?的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: WiFi driver框架的一般层次
- 下一篇: python人工自动抠图_python自