Anvil Co Client Name_receipt.xlsx ADDED
Binary file (5.62 kB). View file
 
Anvil Co Client Name_receiptqq.xlsx ADDED
Binary file (5.62 kB). View file
 
de.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+
3
+ def upload_file(file_path, file_type):
4
+ # Here you can implement the logic for uploading the file
5
+ print(f"Uploading {file_type} file: {file_path}")
6
+
7
+ # Open the JSON file and load the data
8
+ with open("respons12.json", "r") as f:
9
+ data = json.load(f)
10
+
11
+ # Extract information from the data
12
+ receipt = data['receipts'][0]
13
+ items = receipt['items']
14
+
15
+ # Print relevant information
16
+ print(f"Your purchase at {receipt['merchant_name']}")
17
+ print("_" * 30)
18
+ print(f"Merchant address: {receipt['merchant_address']}")
19
+ print(f"Merchant phone: {receipt['merchant_phone']}")
20
+ print(f"Region: {receipt['region']}")
21
+
22
+ # Optionally, print the items and their prices
23
+ # for item in items:
24
+ # print(f"{item['description']} - ${item['amount']}")
25
+
26
+ # Upload PDF and images
27
+ pdf_path = "your_pdf_file.pdf"
28
+ image_path = "your_image_file.jpg"
29
+
30
+ upload_file(pdf_path, "PDF")
31
+ upload_file(image_path, "image")
demoi.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import pickle
3
+ import requests
4
+
5
+ url = "https://ocr.asprise.com/api/v1/receipt"
6
+ images = "erty.png"
7
+
8
+ res = requests.post(url,
9
+ data={
10
+ 'api_key': 'TEST',
11
+ 'recognizer': 'auto',
12
+ 'ref_no': 'oct_python_123'
13
+ },
14
+ files={
15
+ 'file': open(images, 'rb')
16
+ })
17
+ with open("respons12.json", "w") as f:
18
+ json.dump(json.loads(res.text), f)
19
+
20
+
21
+
22
+
23
+
24
+
erty.png ADDED
main.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import requests
3
+ with open("respons12.json", "r") as f:
4
+
5
+ data = json.load(f)
6
+ print(data['receipts'][0].keys())
7
+ items =data['receipts'][0]['items']
8
+ print(f"Your purchase at{data['receipts'][0]['merchant_name']}")
9
+
10
+ # for item in items:
11
+ # print(f"{item['description']} - ${item['amount']}")
12
+
13
+
14
+ print("_" * 30)
15
+ print(f"merchant_address:{data['receipts'][0]['merchant_address']}")
16
+ print(f"merchant_phone:{data['receipts'][0]['merchant_phone']}")
17
+ print(f"merchant_name:{data['receipts'][0]['merchant_name']}")
18
+ print(f"region:{data['receipts'][0]['region']}")
receipt1_data.xlsx ADDED
Binary file (5.62 kB). View file
 
receipt23_data.xlsx ADDED
Binary file (5.62 kB). View file
 
receipt2_data.xlsx ADDED
Binary file (5.62 kB). View file
 
receipt_data.xlsx ADDED
Binary file (5.62 kB). View file
 
respons.json ADDED
File without changes
respons12.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"ocr_type": "receipts", "request_id": "P_122.165.62.116_lvm4aeu6_ysm", "ref_no": "oct_python_123", "file_name": "erty.png", "request_received_on": 1714465158558, "success": true, "image_width": 1544, "image_height": 1658, "image_rotation": 0, "recognition_completed_on": 1714465159000, "receipts": [{"merchant_name": "Anvil Co Client Name", "merchant_address": "123 Main Street", "merchant_phone": "+1 555-444-6666", "merchant_website": null, "merchant_tax_reg_no": null, "merchant_company_reg_no": "123567744", "region": null, "mall": null, "country": "US", "state": "CA", "city": "San Francisco", "zip": "94103", "receipt_no": "12345", "date": "2024-05-24", "time": null, "items": [{"amount": 30.0, "category": null, "description": "Blue large widgets", "flags": "", "qty": 2, "remarks": null, "tags": null, "unitPrice": 15.0}, {"amount": 40.0, "category": null, "description": "Green medium widgets", "flags": "", "qty": 4, "remarks": null, "tags": null, "unitPrice": 10.0}, {"amount": 35.0, "category": null, "description": "Red small widgets with logo", "flags": "", "qty": 5, "remarks": null, "tags": null, "unitPrice": 7.0}, {"amount": 105.0, "category": null, "description": "May 30th, 2024", "flags": "", "qty": null, "remarks": null, "tags": null, "unitPrice": null}], "currency": "USD", "total": 105.0, "subtotal": null, "tax": null, "service_charge": null, "tip": null, "payment_method": null, "payment_details": null, "credit_card_type": null, "credit_card_number": null, "ocr_text": " Anvil\n Anvil Co\n Client Name\n 123 Main Street\n Invoice Date: May 24th, 2024 San Francisco CA, 94103\n Invoice No: 12345 hello@useanvil.com\n QTY DESCRIPTION PRICE SUBTOTAL\n 2 Blue large widgets $15.00 $30.00\n 4 Green medium widgets $10.00 $40.00\n 5 Red small widgets with logo $7.00 $35.00\n PAYMENT INFO DUE BY TOTAL DUE\n Account No: 123567744\n May 30th, 2024 $105.00\n Routing No: 120000547\n Thank you! hello@useanvil.com 555 444 6666 useanvil.com", "ocr_confidence": 98.42, "width": 1402, "height": 1507, "avg_char_width": 13.9803, "avg_line_height": 21.6829, "conf_amount": 79, "source_locations": {"date": [[{"x": 47, "y": 350}, {"x": 480, "y": 351}, {"x": 480, "y": 378}, {"x": 47, "y": 377}]], "receipt_no": [[{"x": 55, "y": 399}, {"x": 316, "y": 399}, {"x": 316, "y": 424}, {"x": 55, "y": 423}]], "merchant_company_reg_no": [[{"x": 191, "y": 1224}, {"x": 325, "y": 1224}, {"x": 325, "y": 1240}, {"x": 191, "y": 1240}]], "merchant_name": [[{"x": 55, "y": 261}, {"x": 302, "y": 261}, {"x": 302, "y": 293}, {"x": 55, "y": 293}]], "doc": [[{"x": -3, "y": -12}, {"x": 1539, "y": -12}, {"x": 1539, "y": 1645}, {"x": -3, "y": 1645}]], "merchant_address": [[{"x": 1255, "y": 305}, {"x": 1478, "y": 305}, {"x": 1478, "y": 327}, {"x": 1255, "y": 327}]], "merchant_phone": [[{"x": 1104, "y": 1544}, {"x": 1287, "y": 1544}, {"x": 1287, "y": 1568}, {"x": 1104, "y": 1568}]]}}]}
responsel.json ADDED
File without changes