mfraz commited on
Commit
00ef1a7
·
verified ·
1 Parent(s): 8670bc7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -8
app.py CHANGED
@@ -19,14 +19,14 @@ def generate_financial_statements(file, file_type):
19
  if file_type == "csv":
20
  df = pd.read_csv(file)
21
  context = df.to_string()
22
- elif file_type == "excel":
23
  df = pd.read_excel(file)
24
  context = df.to_string()
25
- elif file_type == "docs":
26
  context = read_docs(file)
27
  else:
28
  st.error("Unsupported file type. Please upload a CSV, Excel, or DOCS file.")
29
- return
30
 
31
  # Define financial statement queries
32
  queries = [
@@ -60,10 +60,13 @@ st.write("Upload your financial data (CSV, Excel, or DOCS) to generate journal,
60
  # File upload
61
  uploaded_file = st.file_uploader("Upload your file", type=["csv", "xlsx", "docx"])
62
  if uploaded_file is not None:
63
- file_type = uploaded_file.name.split(".")[-1]
64
  financial_statements = generate_financial_statements(uploaded_file, file_type)
65
 
66
- # Display results
67
- for statement_type, statement in financial_statements.items():
68
- st.subheader(statement_type)
69
- st.write(statement)
 
 
 
 
19
  if file_type == "csv":
20
  df = pd.read_csv(file)
21
  context = df.to_string()
22
+ elif file_type == "xlsx":
23
  df = pd.read_excel(file)
24
  context = df.to_string()
25
+ elif file_type == "docx":
26
  context = read_docs(file)
27
  else:
28
  st.error("Unsupported file type. Please upload a CSV, Excel, or DOCS file.")
29
+ return None
30
 
31
  # Define financial statement queries
32
  queries = [
 
60
  # File upload
61
  uploaded_file = st.file_uploader("Upload your file", type=["csv", "xlsx", "docx"])
62
  if uploaded_file is not None:
63
+ file_type = uploaded_file.name.split(".")[-1].lower() # Ensure lowercase file type
64
  financial_statements = generate_financial_statements(uploaded_file, file_type)
65
 
66
+ # Display results if financial_statements is not None
67
+ if financial_statements is not None:
68
+ for statement_type, statement in financial_statements.items():
69
+ st.subheader(statement_type)
70
+ st.write(statement)
71
+ else:
72
+ st.error("Failed to generate financial statements. Please check the file type and content.")