credent007 commited on
Commit
eeb5ad5
·
verified ·
1 Parent(s): a24469b

Update json_handling.py

Browse files
Files changed (1) hide show
  1. json_handling.py +9 -9
json_handling.py CHANGED
@@ -37,23 +37,23 @@ def process_whole_doc(file_path):
37
 
38
  complete_json = {}
39
 
40
- PART_NAME = "PART-1 - BILL OF ENTRY SUMMARY" # you can change per doc type
41
 
42
- for image in images:
43
  partial_json = process_document(image)
44
-
45
  # 🔹 Extract only "result"
46
  result_data = partial_json.get("result", {})
47
-
48
  # Ensure structure exists
49
- if PART_NAME not in complete_json:
50
- complete_json[PART_NAME] = [{}]
51
 
52
- if not complete_json[PART_NAME]:
53
- complete_json[PART_NAME].append({})
54
 
55
  # ✅ Merge directly
56
- complete_json[PART_NAME][0].update(result_data)
57
 
58
  return complete_json
59
 
 
37
 
38
  complete_json = {}
39
 
40
+ # PART_NAME = "PART-1 - BILL OF ENTRY SUMMARY" # you can change per doc type
41
 
42
+ for i,image in images:
43
  partial_json = process_document(image)
44
+ print(partial_json)
45
  # 🔹 Extract only "result"
46
  result_data = partial_json.get("result", {})
47
+ page_key = f"Page {i}"
48
  # Ensure structure exists
49
+ # # if PART_NAME not in complete_json:
50
+ # complete_json[] = [{}]
51
 
52
+ # if not complete_json[PART_NAME]:
53
+ # complete_json[PART_NAME].append({})
54
 
55
  # ✅ Merge directly
56
+ complete_json[page_key]=result_data
57
 
58
  return complete_json
59