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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值