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 26
26
27
27
import os
28
28
from PyPDF2 import PdfReader
29
+ from datetime import datetime
29
30
from langchain_groq import ChatGroq
30
31
from langchain .chains import RetrievalQA
31
32
from dotenv import load_dotenv , find_dotenv
41
42
def extract_text_from_pdfs ():
42
43
print (f"Extracting text from PDF files in the folder: '{ 'Source' } '..." )
43
44
all_text = []
45
+
46
+ if len (os .listdir ('Source' )) == 0 :
47
+ print ("Source Folder Empty!" )
48
+ print ("Process exiting..." )
49
+ exit (0 )
50
+
44
51
for file_name in os .listdir ('Source' ):
45
52
if file_name .endswith (".pdf" ):
46
53
file_path = os .path .join ('Source' , file_name )
@@ -97,6 +104,8 @@ def save_mcq_to_file(quiz, file_name="generated_mcq_quiz.txt"):
97
104
os .makedirs (output_folder )
98
105
print (f"Folder '{ output_folder } ' created." )
99
106
107
+ current_time = datetime .now ().strftime ("%Y-%m-%d_%H-%M-%S" )
108
+ file_name = f"generated_mcq_quiz_{ current_time } .txt"
100
109
file_path = os .path .join (output_folder , file_name )
101
110
102
111
print (f"Saving the generated MCQs to file: '{ file_path } '..." )
You can’t perform that action at this time.
0 commit comments