Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,14 +1,19 @@
|
|
1 |
import streamlit as st
|
2 |
import PyPDF2
|
|
|
|
|
3 |
|
4 |
-
def extract_text_from_pdf(
|
5 |
text = ""
|
6 |
-
with
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
|
|
|
|
|
|
12 |
return text
|
13 |
|
14 |
def main():
|
|
|
1 |
import streamlit as st
|
2 |
import PyPDF2
|
3 |
+
import tempfile
|
4 |
+
import os
|
5 |
|
6 |
+
def extract_text_from_pdf(uploaded_file):
|
7 |
text = ""
|
8 |
+
with tempfile.NamedTemporaryFile(delete=False) as tmp_file:
|
9 |
+
tmp_file.write(uploaded_file.read())
|
10 |
+
tmp_file.seek(0)
|
11 |
+
with open(tmp_file.name, "rb") as f:
|
12 |
+
reader = PyPDF2.PdfFileReader(f)
|
13 |
+
num_pages = reader.numPages
|
14 |
+
for page_num in range(num_pages):
|
15 |
+
page = reader.getPage(page_num)
|
16 |
+
text += page.extractText()
|
17 |
return text
|
18 |
|
19 |
def main():
|