Spaces:
Sleeping
Sleeping
Update file_processing.py
Browse files- file_processing.py +8 -13
file_processing.py
CHANGED
@@ -30,20 +30,15 @@ import pandas as pd
|
|
30 |
import docx
|
31 |
import tempfile
|
32 |
from langchain.docstore.document import Document
|
|
|
33 |
def read_pdf(file_path: str) -> str:
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
text = ""
|
42 |
-
for page in doc:
|
43 |
-
text += page.get_text()
|
44 |
-
|
45 |
-
# No need to delete the temporary file - it's done automatically
|
46 |
-
return text
|
47 |
|
48 |
def read_docx(file_path: str) -> str:
|
49 |
doc = docx.Document(file_path)
|
|
|
30 |
import docx
|
31 |
import tempfile
|
32 |
from langchain.docstore.document import Document
|
33 |
+
|
34 |
def read_pdf(file_path: str) -> str:
|
35 |
+
# Open the PDF with fitz
|
36 |
+
doc = fitz.open(file_path)
|
37 |
+
text = ""
|
38 |
+
for page in doc:
|
39 |
+
text += page.get_text()
|
40 |
+
|
41 |
+
return text
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
|
43 |
def read_docx(file_path: str) -> str:
|
44 |
doc = docx.Document(file_path)
|