Created
July 14, 2021 21:19
-
-
Save pokgak/33a4c0c71ffbcb5cfbfed7d225893487 to your computer and use it in GitHub Desktop.
Convert .xlsx files to CSV
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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