• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
There are many songs in the PDF, how to create a Setlist?
#2
I wrote a simple Python script to produce a .CSV file that can be imported into MobileSheets with the PDF file to create separate pieces. It uses the very imperfect method of assuming that all piece titles are in a specific font and size. This is very 'rough and ready' and works for me by manually editing it to change the input PDF file and the title font as needed. This was only ever intended for my personal use and is very far from being a 'production ready' program.

The only dependency is py-pdf-parser, which can be installed using pip.

The .CSV file is output to the terminal by default, but can be redirected to a files using the ">" operator (E.g. "python3 splitpdfmusic.py > OUTPUT_FILE.csv".)

Code:
# Generate index for MobileSheets

from py_pdf_parser.loaders import load_file
from py_pdf_parser.visualise import visualise

document = load_file("FILE PATH HERE")
#print(document.fonts)  # Uncomment to display a list of fonts used in the document
headers = document.elements.filter_by_font("LDOJID+Verdana-Bold,9.8")  # Change font and size here
print("title;pages")
for h in headers:
    s = h.text().split('\n')[0]
    print(f'"{s}";{h.page_number}-{h.page_number}')


#visualise(document)  # Uncomment for debugging
Reply


Messages In This Thread
RE: There are many songs in the PDF, how to create a Setlist? - by chris_i - 09-26-2024, 06:29 AM



Users browsing this thread:
2 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2024 MyBB Group.