Spaces:
Sleeping
Sleeping
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) | |
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' | |
) |