nazianafis's picture
Update app.py
f40ddc3 verified
raw
history blame contribute delete
700 Bytes
import streamlit as st
import camelot as cam
st.title("Extract Tables from PDFs")
input_pdf = st.file_uploader("Upload PDF here", type="pdf")
page_number = st.text_input(
"Enter page number(s) (e.g. 1 or 1-3)",
value="1"
)
if input_pdf is not None:
with open("input.pdf", "wb") as f:
f.write(input_pdf.read())
tables = cam.read_pdf(
"input.pdf",
pages=page_number,
flavor="stream"
)
st.markdown("## Number of Tables")
st.write(len(tables))
if len(tables) > 0:
option = st.selectbox(
"Select the table to display",
options=list(range(len(tables)))
)
st.dataframe(tables[option].df)