1

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.

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)
milanbalazs
  • 4,811
  • 4
  • 23
  • 45
Aditya
  • 11
  • 5

1 Answers1

0

Once you read the excel and stored it in pandas dataframe save it as

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)
Rikigami
  • 63
  • 5