简体   繁体   English

我可以使用 python 将 xlsb 文件转换为 xlsx 吗?

[英]Can i convert xlsb file to xlsx using python?

I was trying to convert xlsb file to xlsx using Python but I am not able to figure out my problem in my all unsuccessful attempts.我试图使用 Python 将xlsb文件转换为xlsx但我无法在所有不成功的尝试中找出我的问题。

Code:代码:

import pandas as pd
import os
import glob


source='C:\\Users\\JS Developer\\sample.xlsb'
dest= 'C:\\Users\\JS Developer\\Desktop\\New folder'
os.chdir(source)

for file in glob.glob("*.xlb"):
  df.to_csv(dest+file+'.csv', index=False)
  os.remove(file)

for file in glob.glob("*.xlsb"):
       df = pd.read_excel(file)
       df.to_csv(dest+file+'.csv', index=False)
       os.remove(file)

Once you read the excel and stored it in pandas dataframe save it as一旦您阅读了 excel 并将其存储在 Pandas 数据框中,将其另存为

df.to_excel(r'Path\name.xlsx')

Try:尝试:

for file in glob.glob("*.xlsb"):
   df = pd.read_excel(file)
   df.to_excel(dest+file+'.xlsx', index = None, header=True)
   os.remove(file)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM