Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -179,6 +179,34 @@ class FinancialAnalyzer:
|
|
179 |
print(f"Error calculating metrics: {str(e)}")
|
180 |
return {}
|
181 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
182 |
def generate_analysis(self, metrics):
|
183 |
"""Generate comprehensive analysis"""
|
184 |
try:
|
|
|
179 |
print(f"Error calculating metrics: {str(e)}")
|
180 |
return {}
|
181 |
|
182 |
+
|
183 |
+
def analyze_financials(self, balance_sheet_path, income_statement_path):
|
184 |
+
try:
|
185 |
+
# Validate markdown files
|
186 |
+
if not self.is_valid_markdown(balance_sheet_path):
|
187 |
+
return "Invalid Balance Sheet file format. Please upload a valid Markdown file."
|
188 |
+
if not self.is_valid_markdown(income_statement_path):
|
189 |
+
return "Invalid Income Statement file format. Please upload a valid Markdown file."
|
190 |
+
|
191 |
+
# Read and parse files
|
192 |
+
with open(balance_sheet_path, 'r') as f:
|
193 |
+
balance_content = f.read()
|
194 |
+
with open(income_statement_path, 'r') as f:
|
195 |
+
income_content = f.read()
|
196 |
+
|
197 |
+
balance_data = self.parse_financial_data(balance_content)
|
198 |
+
income_data = self.parse_financial_data(income_content)
|
199 |
+
|
200 |
+
# Calculate metrics
|
201 |
+
metrics = self.calculate_metrics(income_data, balance_data)
|
202 |
+
|
203 |
+
# Generate analysis
|
204 |
+
return self.generate_analysis(metrics)
|
205 |
+
|
206 |
+
except Exception as e:
|
207 |
+
return f"Error analyzing financials: {e}"
|
208 |
+
|
209 |
+
|
210 |
def generate_analysis(self, metrics):
|
211 |
"""Generate comprehensive analysis"""
|
212 |
try:
|