qq1023 commited on
Commit
b598d53
·
1 Parent(s): 1a0823d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -10
app.py CHANGED
@@ -206,6 +206,7 @@ def process_and_output_files(input_files):
206
  data = []
207
 
208
  total_amount = 0
 
209
 
210
  for file in input_files:
211
  # Extract and categorize text for each file
@@ -225,29 +226,49 @@ def process_and_output_files(input_files):
225
  # )
226
 
227
  response_dict = json.loads(chats[1]["value"][0][1])
228
- if category == "RANDOM":
229
- category = response_dict.get("summary")
230
  # Extract the relevant data
231
- extracted_data = {
232
- "Nature of Expenditure": response_dict.get("summary",category),
233
- "Bill/Invoice No.": response_dict.get("uids"),
234
- "Amount(Rs.)": response_dict.get("total")
235
- }
 
 
 
 
 
 
 
 
 
 
236
 
237
  total_amount+=response_dict.get("total")
238
 
239
  # Append the relevant data for this file to the data list
240
  data.append(extracted_data)
241
-
242
 
 
 
 
 
 
 
 
 
 
 
243
  string_data = []
244
  for item in data:
245
  string_item = {key: str(value) for key, value in item.items()}
246
  string_data.append(string_item)
 
247
 
248
  df = pd.DataFrame(string_data)
249
- table_html = df.to_html(classes="table table-bordered", index=True)
250
-
 
251
  scrollable_table = f'<div style="overflow-x: auto;">{table_html}</div>'
252
  return scrollable_table
253
 
 
206
  data = []
207
 
208
  total_amount = 0
209
+ item_no = 1
210
 
211
  for file in input_files:
212
  # Extract and categorize text for each file
 
226
  # )
227
 
228
  response_dict = json.loads(chats[1]["value"][0][1])
229
+ if response_dict.get("summary") :
 
230
  # Extract the relevant data
231
+
232
+ extracted_data = {
233
+ "S.No.": item_no,
234
+ "Nature of Expenditure": response_dict.get("summary"),
235
+ "Bill/Invoice No.": response_dict.get("uids"),
236
+ "Amount(Rs.)": response_dict.get("total")
237
+ }
238
+ else:
239
+ extracted_data = {
240
+ "S.No.": item_no,
241
+ "Nature of Expenditure": category,
242
+ "Bill/Invoice No.": response_dict.get("uids"),
243
+ "Amount(Rs.)": response_dict.get("total")
244
+ }
245
+
246
 
247
  total_amount+=response_dict.get("total")
248
 
249
  # Append the relevant data for this file to the data list
250
  data.append(extracted_data)
 
251
 
252
+ item_no=item_no+1
253
+
254
+ total_data = {
255
+ "S.No.": ""
256
+ "Nature of Expenditure": "Total Amount",
257
+ "Bill/Invoice No.": "",
258
+ "Amount(Rs.)": total_amount
259
+ }
260
+ data.append(total_data)
261
+
262
  string_data = []
263
  for item in data:
264
  string_item = {key: str(value) for key, value in item.items()}
265
  string_data.append(string_item)
266
+
267
 
268
  df = pd.DataFrame(string_data)
269
+
270
+ table_html = df.to_html(classes="table table-bordered", index=False)
271
+
272
  scrollable_table = f'<div style="overflow-x: auto;">{table_html}</div>'
273
  return scrollable_table
274