Skip to content

Instantly share code, notes, and snippets.

@juanluisrto
Last active May 20, 2020 12:43
Show Gist options
  • Save juanluisrto/66e2bf157ab32719210cdcac2327f3a3 to your computer and use it in GitHub Desktop.
Save juanluisrto/66e2bf157ab32719210cdcac2327f3a3 to your computer and use it in GitHub Desktop.
import pandas as pd, os, shutil
df = pd.read_excel("Free+English+textbooks.xlsx")
for cat in df["English Package Name"].unique():
os.mkdir("download/" + cat)
for index, row in df.iterrows():
category = row.loc["English Package Name"]
file_name = f"{row.loc['Book Title']}_{row.loc['Edition']}".replace('/','-').replace(':','-')
shutil.move(f"download/{file_name}.pdf", f"download/{category}/{file_name}.pdf")
@lucasbomb
Copy link

Hello! I tryed to use this script (OSX) but i got this error:
Schermata 2020-05-03 alle 14 47 16

@juanluisrto
Copy link
Author

It seems you are having issues with f-string formatting. This was included in python 3.6.
Are you using python 3.6 or above?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment