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

标签 python excel pandas machine-learning analytics

我尝试使用 Python 将 xlsb 文件转换为 xlsx,但在所有不成功的尝试中我无法找出问题所在。

代码:

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)

最佳答案

读取 Excel 并将其存储在 pandas 数据框中后,将其另存为

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

尝试:

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

关于python - 我可以使用 python 将 xlsb 文件转换为 xlsx 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59558961/

相关文章:

python - 当 terraform 从 python 子进程运行时,为什么 args 被 '=' 分割

python - 使用 AWS CDK 创建受 MFA 保护的角色会绕过 MFA 条件

excel - 显示单元格中选定的切片器项目

vba - 以编程方式重命名 activeX 文本框 "(name)"字段

Excel:用于将公式向下拖动到列末尾的宏

python - 如何在 Beautiful Soup 4 中插入未转义的 html 片段

python - 在 Ubuntu 14.04 可信服务器上使用 nginx 和 Gunicorn 的多个 Django 应用程序

python - 根据值分离数据

python - 对具有相同名称的行进行分组的最佳方法

python - 将 Pandas 数据框转换为字典字典