I have a pandas dataframe, pdf_summary, which is sorted and has 50 unique rows. Each row is a particular combination of file_pages. How could I create a folder and PDF for each file_name?
pdf_path = "Documents/menu.pdf"
pdf_summary
file_name file_pages_to_keep
1 - Monday, Wednesday 1,3
2 - Monday 1
3 - Monday, Tuesday, Wednesday 1,2,3
...
50 - Friday 5
The expected output would be 50 folders, with one PDF inside each folder with only those file_pages taken from the menu.pdf.
"Documents/1 - Monday, Wednesday/1 - Monday, Wednesday.pdf" (PDF only has pages 1 and 3 from menu.pdf)
...
first, you define a function for writing a pdf into a folder that allows you to select the pages:
Then you iterate over the rows of your df and for every row, you store the name of the pdf file (based on the file_name column) and the pages that you have to write: