Published on
248 words2 min read––– views

How to convert multiple xslb files to csv with python

How to convert multiple xslb files to csv with python

Manually converting xslb to csv is fine if you don't have too many xslb files and if you have xslb with smaller file size.

But, if you need to convert too many xslb files to csv, you can easily convert as many files you want using this simple python script.

Step 1:

  • Install python. Make sure you select 'Add Python 3.7 to PATH' during python installation.
  • Install pypiwin32 from command prompt using:
    pip install pypiwin32

Step 2:

# import packages and set the xslb files directory path:
import os
import sys
import datetime
import win32com.client
import glob
excel = win32com.client.Dispatch("Excel.Application")
# use glob to match the pattern 'xslb'
excel_files = glob.glob(filePath+'\*.xlsb')
for excel1 in excel_files:
file = excel1.split('.')[0]+'.csv'
doc =

Save the above script as and run the script from command prompt using following line of code:

python C:\Users\faisal\Desktop\

or you can create a batch file with the above single line of code or run the script using any python ide.

After running the script you will have both xslb and csv files in same folder. You can sort by file types and separate csv files and xslb files.

The completed script for this how-to is documented on Github.