Skip to content

Instantly share code, notes, and snippets.

@araastat
Created March 5, 2014 13:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save araastat/9366807 to your computer and use it in GitHub Desktop.
Save araastat/9366807 to your computer and use it in GitHub Desktop.
Export each sheet of a xls/xlsx file to csv
import pandas as pd
import xlrd as xd
def xls2csv(f, index=False, header=True):
wb = xd.open_workbook(f)
snames=[]
for s in wb.sheets():
snames.append(s.name)
for s in snames:
x = pd.read_excel(f,s)
x.to_csv(''.join(s.split(' '))+'.csv', index=index, header=header)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment