Skip to content

Instantly share code, notes, and snippets.

@pokgak
Created July 14, 2021 21:19
Show Gist options
  • Save pokgak/33a4c0c71ffbcb5cfbfed7d225893487 to your computer and use it in GitHub Desktop.
Save pokgak/33a4c0c71ffbcb5cfbfed7d225893487 to your computer and use it in GitHub Desktop.
Convert .xlsx files to CSV
import os
import pandas as pd
for file in os.listdir():
if not file.endswith(".xlsx"):
continue
try:
f_xls = pd.read_excel(file, engine="openpyxl")
f_xls.to_csv(f"{file.split('.')[0]}.csv", encoding="utf-8", index=False)
except Exception:
print(f"{file} conversion failed")
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment