-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
40 lines (33 loc) · 1.17 KB
/
main.py
File metadata and controls
40 lines (33 loc) · 1.17 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
import streamlit as st
import invoiceutil as util
def main():
st.set_page_config(
page_title='Extraction Bot',
page_icon=':pencil:'
)
st.title('Invoice Extraction Bot :rocket:')
st.write("""Let's save your time extracting invoice data!""")
# Upload invoice file(s)
uploaded_files = st.file_uploader(
'Upload your invoice(s). Only pdf format supported',
type=['pdf'],
accept_multiple_files=True,
)
submit = st.button('Extract')
if submit:
with st.spinner('Extracting data...'):
df = util.create_documents(uploaded_files)
# Display the first columns of the invoice dataframe
st.write(df.head())
# Provide the invoice data in csv format for download
invoice_csv = df.to_csv(index=False).encode('utf-8')
st.download_button(
label='Download Invoice',
data=invoice_csv,
file_name='invoice_data.csv',
mime='text/csv',
key='csv-download-invoice',
)
st.success('Invoice Extracted Successfully!')
if __name__ == '__main__':
main()