Skip to content

Instantly share code, notes, and snippets.

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 iraklidd/1d17aa351608eb69118888aed2260269 to your computer and use it in GitHub Desktop.
Save iraklidd/1d17aa351608eb69118888aed2260269 to your computer and use it in GitHub Desktop.
save excel sheets as csv files, using python (jupyter notebook)
import os
import pandas as pd
from datetime import date
f_name = 'Samle Data.xlsx' # Enter excel file name (from the same directory)
prfx = os.path.splitext(f_name)[0] # you can change prefix
sffx = datetime.today().strftime('%Y-%m-%d') # or suffix
WS = pd.ExcelFile(f_name)
for i in range(len(WS.sheet_names)):
df = pd.read_excel(f_name, sheet_name=WS.sheet_names[i], dtype=str)
df.to_csv(prfx + '_' + WS.sheet_names[i] + '_' + sffx + '.csv', sep=',', header=True, index=False, encoding='utf-8')
WS.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment