Finance-master / app.py
mfraz's picture
Update app.py
17a7a8f verified
raw
history blame
1.82 kB
# 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.")