Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| import os | |
| from invoice_convertor import InvoiceConvertor | |
| def main(): | |
| st.set_page_config(layout="wide") | |
| st.title('Amazon Invoice Convertor') | |
| st.write('This app converts your Amazon invoice pdfs to a csv file.') | |
| st.write('Please make sure the name of your pdf files start with "invoice".') | |
| convertor = InvoiceConvertor() | |
| files = st.file_uploader('Upload your invoice pdfs', type=['pdf'], accept_multiple_files=True) | |
| if files: | |
| for file in files: | |
| with open('data/' + file.name, 'wb') as f: | |
| f.write(file.getbuffer()) | |
| convertor.read_pdfs('data/') | |
| result_df = convertor.convert() | |
| st.write(result_df) | |
| st.download_button('Download csv', data=result_df.to_csv(), file_name='invoice.csv', mime='text/csv') | |
| for file in os.listdir('data/'): | |
| os.remove('data/' + file) | |
| if st.button('Clear csv file') and os.path.exists('invoice.csv'): | |
| os.remove('invoice.csv') | |
| if __name__ == '__main__': | |
| main() |