python保存为xlsb_如何使用Python将csv文件转换为xlsb?
我想將csv文件轉(zhuǎn)換為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格式.我發(fā)現(xiàn)這個XlFileFormat Enumeration (Excel)有可用的值,但我不確定哪一個是我需要的.
有用提示:如果有人嘗試轉(zhuǎn)換第一行中第一項(xiàng)的csv是ID,則會發(fā)生錯誤.將ID更改為id,它會沒問題,更多信息SYLK: File format is not valid.
總結(jié)
以上是生活随笔為你收集整理的python保存为xlsb_如何使用Python将csv文件转换为xlsb?的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: WiFi driver框架的一般层次
- 下一篇: 学生资质领取阿里云7个月免费服务器,飞天