Spaces:
Sleeping
Sleeping
File size: 1,821 Bytes
726d9b4 17a7a8f 726d9b4 17a7a8f 726d9b4 17a7a8f 726d9b4 17a7a8f 726d9b4 17a7a8f 726d9b4 17a7a8f 726d9b4 17a7a8f 726d9b4 17a7a8f 726d9b4 |
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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# app.py
import streamlit as st
import pandas as pd
import docx
def process_financial_data(file):
try:
if file.name.endswith('.csv'):
df = pd.read_csv(file)
elif file.name.endswith(('.xls', '.xlsx')):
df = pd.read_excel(file)
elif file.name.endswith('.docx'):
doc = docx.Document(file)
data = []
for para in doc.paragraphs:
data.append(para.text)
df = pd.DataFrame({'Content': data})
else:
st.error("Unsupported file format. Please upload a CSV, Excel, or Word document.")
return None, None, None
if 'Type' in df.columns:
income_statement = df[df['Type'] == 'Income Statement']
balance_sheet = df[df['Type'] == 'Balance Sheet']
cash_flow = df[df['Type'] == 'Cash Flow Statement']
return income_statement, balance_sheet, cash_flow
else:
return df, None, None
except Exception as e:
st.error(f"Error processing file: {e}")
return None, None, None
st.title("Financial Accounting App")
st.write("Upload a financial data file (CSV, Excel, Word) to generate statements.")
uploaded_file = st.file_uploader("Upload a file", type=["csv", "xls", "xlsx", "docx"])
if uploaded_file is not None:
income_stmt, balance_sht, cash_flw = process_financial_data(uploaded_file)
if income_stmt is not None:
st.subheader("Processed Data")
st.dataframe(income_stmt)
if balance_sht is not None:
st.subheader("Balance Sheet")
st.dataframe(balance_sht)
if cash_flw is not None:
st.subheader("Cash Flow Statement")
st.dataframe(cash_flw)
st.write("Developed for financial statement analysis.")
|