• 58 Posts
  • 21 Comments
Joined 1 year ago
cake
Cake day: June 6th, 2023

help-circle







































  • Wilshire@beehaw.orgtoPython@lemmy.ml*Permanently Deleted*
    link
    fedilink
    English
    arrow-up
    0
    ·
    1 year ago

    If you’re reading the file path from standard input, you could try using the os.path.normpath() function from the os module to normalize the file path before passing it to the PdfReader function. This function converts a pathname to the normal form for the current operating system, which could help resolve any issues with the file path.

    Here’s an example of how you could use this function:

    import os
    from PyPDF2 import PdfReader
    
    def main():
        path = input('Whatever: ')
        normalized_path = os.path.normpath(path)
        reader = PdfReader(normalized_path)
    

    Give this a try and let me know if it helps!