Spaces:
Sleeping
Sleeping
File size: 732 Bytes
144abd2 b1fcfaa 91416d9 37e4b8d 7c5fd00 b1fcfaa a56763e b1fcfaa |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
import os
import streamlit as st
from tablecv import extract_table
img_name = st.file_uploader("Upload an image with table(s)")
if img_name is not None:
st.image(img_name)
isExist = os.path.exists("upload_file")
if not isExist:
os.makedirs("upload_file")
with open("upload_file/"+img_name.name, "wb") as f:
f.write(img_name.getbuffer())
extracted_tables = extract_table(image_path="upload_file/"+img_name.name)
@st.cache_data
def convert_df(df):
return df.to_csv(index=False).encode('utf-8')
csv = convert_df(extracted_tables)
st.table(extracted_tables)
st.download_button(
"Press to Download",
csv,
"file.csv",
"text/csv",
key='download-csv'
) |