File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change 2626
2727import os
2828from PyPDF2 import PdfReader
29+ from datetime import datetime
2930from langchain_groq import ChatGroq
3031from langchain .chains import RetrievalQA
3132from dotenv import load_dotenv , find_dotenv
4142def extract_text_from_pdfs ():
4243 print (f"Extracting text from PDF files in the folder: '{ 'Source' } '..." )
4344 all_text = []
45+
46+ if len (os .listdir ('Source' )) == 0 :
47+ print ("Source Folder Empty!" )
48+ print ("Process exiting..." )
49+ exit (0 )
50+
4451 for file_name in os .listdir ('Source' ):
4552 if file_name .endswith (".pdf" ):
4653 file_path = os .path .join ('Source' , file_name )
@@ -97,6 +104,8 @@ def save_mcq_to_file(quiz, file_name="generated_mcq_quiz.txt"):
97104 os .makedirs (output_folder )
98105 print (f"Folder '{ output_folder } ' created." )
99106
107+ current_time = datetime .now ().strftime ("%Y-%m-%d_%H-%M-%S" )
108+ file_name = f"generated_mcq_quiz_{ current_time } .txt"
100109 file_path = os .path .join (output_folder , file_name )
101110
102111 print (f"Saving the generated MCQs to file: '{ file_path } '..." )
You can’t perform that action at this time.
0 commit comments