Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
|
3 |
import streamlit as st
|
4 |
import pandas as pd
|
5 |
-
import
|
6 |
|
7 |
def process_financial_data(file):
|
8 |
try:
|
@@ -11,44 +11,56 @@ def process_financial_data(file):
|
|
11 |
elif file.name.endswith(('.xls', '.xlsx')):
|
12 |
df = pd.read_excel(file)
|
13 |
elif file.name.endswith('.docx'):
|
14 |
-
doc =
|
15 |
-
data = []
|
16 |
-
for para in doc.paragraphs:
|
17 |
-
data.append(para.text)
|
18 |
df = pd.DataFrame({'Content': data})
|
19 |
else:
|
20 |
st.error("Unsupported file format. Please upload a CSV, Excel, or Word document.")
|
21 |
-
return None, None, None
|
22 |
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
30 |
except Exception as e:
|
31 |
st.error(f"Error processing file: {e}")
|
32 |
-
return None, None, None
|
33 |
|
34 |
-
st.title("Financial Accounting App")
|
35 |
-
st.write("Upload a financial data file (CSV, Excel, Word) to generate
|
36 |
|
37 |
uploaded_file = st.file_uploader("Upload a file", type=["csv", "xls", "xlsx", "docx"])
|
38 |
|
39 |
if uploaded_file is not None:
|
40 |
-
income_stmt, balance_sht, cash_flw = process_financial_data(uploaded_file)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
if income_stmt is not None:
|
43 |
-
st.subheader("
|
44 |
st.dataframe(income_stmt)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
|
46 |
-
|
47 |
-
st.subheader("Balance Sheet")
|
48 |
-
st.dataframe(balance_sht)
|
49 |
-
|
50 |
-
if cash_flw is not None:
|
51 |
-
st.subheader("Cash Flow Statement")
|
52 |
-
st.dataframe(cash_flw)
|
53 |
|
54 |
-
st.write("Developed for financial statement analysis.")
|
|
|
2 |
|
3 |
import streamlit as st
|
4 |
import pandas as pd
|
5 |
+
from docx import Document
|
6 |
|
7 |
def process_financial_data(file):
|
8 |
try:
|
|
|
11 |
elif file.name.endswith(('.xls', '.xlsx')):
|
12 |
df = pd.read_excel(file)
|
13 |
elif file.name.endswith('.docx'):
|
14 |
+
doc = Document(file)
|
15 |
+
data = [para.text for para in doc.paragraphs if para.text.strip()]
|
|
|
|
|
16 |
df = pd.DataFrame({'Content': data})
|
17 |
else:
|
18 |
st.error("Unsupported file format. Please upload a CSV, Excel, or Word document.")
|
19 |
+
return None, None, None, None, None
|
20 |
|
21 |
+
# Creating Ledger
|
22 |
+
ledger = df[df['Type'] == 'Ledger'] if 'Type' in df.columns else None
|
23 |
+
|
24 |
+
# Creating Journal
|
25 |
+
journal = df[df['Type'] == 'Journal'] if 'Type' in df.columns else None
|
26 |
+
|
27 |
+
# Creating Financial Statements
|
28 |
+
income_statement = df[df['Type'] == 'Income Statement'] if 'Type' in df.columns else None
|
29 |
+
balance_sheet = df[df['Type'] == 'Balance Sheet'] if 'Type' in df.columns else None
|
30 |
+
cash_flow = df[df['Type'] == 'Cash Flow Statement'] if 'Type' in df.columns else None
|
31 |
+
|
32 |
+
return ledger, journal, income_statement, balance_sheet, cash_flow
|
33 |
except Exception as e:
|
34 |
st.error(f"Error processing file: {e}")
|
35 |
+
return None, None, None, None, None
|
36 |
|
37 |
+
st.title("Comprehensive Financial Accounting App")
|
38 |
+
st.write("Upload a financial data file (CSV, Excel, Word) to generate Ledger, Journal, and Financial Statements.")
|
39 |
|
40 |
uploaded_file = st.file_uploader("Upload a file", type=["csv", "xls", "xlsx", "docx"])
|
41 |
|
42 |
if uploaded_file is not None:
|
43 |
+
ledger, journal, income_stmt, balance_sht, cash_flw = process_financial_data(uploaded_file)
|
44 |
+
|
45 |
+
if ledger is not None:
|
46 |
+
st.subheader("Ledger")
|
47 |
+
st.dataframe(ledger)
|
48 |
+
|
49 |
+
if journal is not None:
|
50 |
+
st.subheader("Journal")
|
51 |
+
st.dataframe(journal)
|
52 |
|
53 |
if income_stmt is not None:
|
54 |
+
st.subheader("Income Statement")
|
55 |
st.dataframe(income_stmt)
|
56 |
+
|
57 |
+
if balance_sht is not None:
|
58 |
+
st.subheader("Balance Sheet")
|
59 |
+
st.dataframe(balance_sht)
|
60 |
+
|
61 |
+
if cash_flw is not None:
|
62 |
+
st.subheader("Cash Flow Statement")
|
63 |
+
st.dataframe(cash_flw)
|
64 |
|
65 |
+
st.write("Developed for comprehensive financial analysis.")
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
|
|