pls see below code # Importing required modules PdfReader = PyPDF2.PdfFileReader(os.path.join(foldername, file)) I’ve cleaned up the code a little and removed some duplicated imports and unused lines below: # Importing required modulesįor foldername, subfolders, files in os.walk(r"C:/Users/ambar/OneDrive/Desktop/dummy/dummy1"): ```if any(word in line for word in word):īy “wrapping the code in backticks” I mean put 3 backticks ``` on a line before and a line after the code, as in my original reply.Īs for the other matter, you just need to clear the lines for each file. #pdfReader = PyPDF2.PdfFileReader(pdfFileObj) ```pdfReader = PyPDF2.PdfFileReader(os.path.join(foldername,file)) ```for foldername,subfolders,files in os.walk(r"C:/Users/ambar/OneDrive/Desktop/dummy/dummy1"): thanks again Importing required modules ```import os Pls can you let me know which lines I need to make changes?. after then it starts to append lines and prints name of wrong pdf against these lines. below code works fine for printing name of first few pdfs. I want to loop through all the pdf files in folder, look for keyword and print the lines where keyword found with the name of pdf where this keyword is found. #Pages = pdfFileObj.getNumPages() Loop for reading all the Pages for i in range(pages): PdfReader = PyPDF2.PdfFileReader(os.path.join(foldername,file))Ĭreating a pdf reader object #pdfReader = PyPDF2.PdfFileReader(pdfFileObj) Word = įor foldername,subfolders,files in os.walk(r"C:/Users/ambar/OneDrive/Desktop/dummy/dummy1"): for file in files: below code works fine for printing of few pdfs.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |