日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 >

python保存为xlsb_如何使用Python将csv文件转换为xlsb?

發(fā)布時間:2024/3/26 51 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python保存为xlsb_如何使用Python将csv文件转换为xlsb? 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

我想將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)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。