Spaces:
Runtime error
Runtime error
import streamlit as st | |
from annotated_text import annotated_text, annotation | |
import os | |
import uuid | |
from pathlib import Path | |
import json | |
#import camelot | |
import camelot.io as camelot | |
st.title("Tables Inside Native Pdf") | |
def util_upload_file_and_return_list_docs(uploaded_file): | |
save_path = Path(os.getcwd(), uploaded_file.name) | |
with open(save_path, mode='wb') as w: | |
w.write(uploaded_file.getvalue()) | |
print('save_path:', save_path) | |
return(save_path) | |
with st.form("my_form"): | |
multi = '''1. Upload a Contract | |
e.g. https://camelot-py.readthedocs.io/en/master/_static/pdf/foo.pdf | |
''' | |
st.markdown(multi) | |
multi = '''2. Press Calculate.''' | |
st.markdown(multi) | |
multi = '''*** Works Only On Native PDF (Not Scanned) ***''' | |
st.markdown(multi) | |
uploaded_file = st.file_uploader("Choose a file") | |
print('uploaded_file :: ',uploaded_file) | |
if uploaded_file is not None: | |
save_path = str(util_upload_file_and_return_list_docs(uploaded_file)) | |
print('type(save_path)',type(save_path)) | |
submitted = st.form_submit_button("Calculate") | |
if submitted and (uploaded_file is not None): | |
tables = camelot.read_pdf(save_path) | |
for table in tables: | |
st.write(table.df) | |