fschwartzer commited on
Commit
14a3d68
1 Parent(s): 7b357aa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -121,12 +121,16 @@ if not filtered_df.empty:
121
  for _, row in conta_df.iterrows():
122
  # Split the 'Forecasts' column's multiline string into lines
123
  lines = row['Forecasts'].split('\n')
124
- # For each line, extract the numeric value and add it to the conta_sum
125
- for line in lines:
126
  if line.strip(): # Ensure the line is not empty
127
  parts = line.split()
128
  value = parts[-1] # Take the last element as the value
129
- conta_sum += float(value)
 
 
 
 
130
 
131
  # Format the sum as a monetary value
132
  monetary_value = f'R$ {conta_sum:,.2f}'
 
121
  for _, row in conta_df.iterrows():
122
  # Split the 'Forecasts' column's multiline string into lines
123
  lines = row['Forecasts'].split('\n')
124
+ # For each line, except the last summary line, extract the numeric value and add it to the conta_sum
125
+ for line in lines[:-1]: # Skip the last line, which contains the summary
126
  if line.strip(): # Ensure the line is not empty
127
  parts = line.split()
128
  value = parts[-1] # Take the last element as the value
129
+ try:
130
+ conta_sum += float(value)
131
+ except ValueError:
132
+ # Handle unexpected lines that cannot be converted to float
133
+ print(f"Skipping line unable to convert to float: {line}")
134
 
135
  # Format the sum as a monetary value
136
  monetary_value = f'R$ {conta_sum:,.2f}'