Spaces:
Runtime error
Runtime error
app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
import streamlit as st
|
2 |
import time
|
3 |
-
import
|
4 |
from openai import OpenAI
|
5 |
from docx import Document
|
6 |
from docx.shared import Pt
|
@@ -44,14 +44,14 @@ for message in st.session_state.messages:
|
|
44 |
uploaded_file = st.file_uploader("Upload PDF file", type=["pdf"])
|
45 |
|
46 |
if uploaded_file:
|
47 |
-
# Read the PDF file using
|
48 |
-
|
49 |
full_text = ""
|
50 |
|
51 |
# Extract text from each page
|
52 |
-
for page_num in range(
|
53 |
-
page =
|
54 |
-
full_text += page.
|
55 |
|
56 |
st.write("Text extracted from PDF:")
|
57 |
st.text_area("Extracted Text", full_text, height=300)
|
|
|
1 |
import streamlit as st
|
2 |
import time
|
3 |
+
import PyPDF2 # Import PyPDF2 for PDF text extraction
|
4 |
from openai import OpenAI
|
5 |
from docx import Document
|
6 |
from docx.shared import Pt
|
|
|
44 |
uploaded_file = st.file_uploader("Upload PDF file", type=["pdf"])
|
45 |
|
46 |
if uploaded_file:
|
47 |
+
# Read the PDF file using PyPDF2
|
48 |
+
pdf_reader = PyPDF2.PdfReader(uploaded_file)
|
49 |
full_text = ""
|
50 |
|
51 |
# Extract text from each page
|
52 |
+
for page_num in range(len(pdf_reader.pages)):
|
53 |
+
page = pdf_reader.pages[page_num]
|
54 |
+
full_text += page.extract_text()
|
55 |
|
56 |
st.write("Text extracted from PDF:")
|
57 |
st.text_area("Extracted Text", full_text, height=300)
|