Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
CHANGED
@@ -28,13 +28,12 @@ def process_resumes(job_description, uploaded_files):
|
|
28 |
content = content.encode("utf-8")
|
29 |
f.write(content)
|
30 |
|
31 |
-
# Read
|
32 |
if ext == "txt":
|
33 |
with open(file_path, "r", encoding="utf-8") as f:
|
34 |
text = f.read()
|
35 |
|
36 |
elif ext == "pdf":
|
37 |
-
import pdfplumber
|
38 |
try:
|
39 |
with pdfplumber.open(file_path) as pdf:
|
40 |
pages = [page.extract_text() for page in pdf.pages if page.extract_text() is not None]
|
@@ -45,8 +44,11 @@ def process_resumes(job_description, uploaded_files):
|
|
45 |
return f"Failed to process PDF {filename}: {str(e)}", None
|
46 |
|
47 |
elif ext == "docx":
|
48 |
-
|
49 |
-
|
|
|
|
|
|
|
50 |
|
51 |
else:
|
52 |
return f"Unsupported file format: {filename}", None
|
|
|
28 |
content = content.encode("utf-8")
|
29 |
f.write(content)
|
30 |
|
31 |
+
# Read file content depending on extension
|
32 |
if ext == "txt":
|
33 |
with open(file_path, "r", encoding="utf-8") as f:
|
34 |
text = f.read()
|
35 |
|
36 |
elif ext == "pdf":
|
|
|
37 |
try:
|
38 |
with pdfplumber.open(file_path) as pdf:
|
39 |
pages = [page.extract_text() for page in pdf.pages if page.extract_text() is not None]
|
|
|
44 |
return f"Failed to process PDF {filename}: {str(e)}", None
|
45 |
|
46 |
elif ext == "docx":
|
47 |
+
try:
|
48 |
+
doc = Document(file_path)
|
49 |
+
text = "\n".join([p.text for p in doc.paragraphs])
|
50 |
+
except Exception as e:
|
51 |
+
return f"Failed to process DOCX {filename}: {str(e)}", None
|
52 |
|
53 |
else:
|
54 |
return f"Unsupported file format: {filename}", None
|