I have three variable data, gptresponse, ocrtext. Data and gptresponse are dictionary…
- User
I have three variable data, gpt_response, ocr_text. Data and gpt_response are dictionary and ocr_text is list. data = {'1 TO 1 HelpNet.PDF': {'ocr_text1': 'Current Account', 'ent2replace': {'invoice_details': {'invoice_number': '575'}, 'line_items': [{'s_no': '1', 'date_of_line_item': '', 'hsn_code': '99839967', 'description': 'EAP Services From 01-Jan-23 to 31-Mar-23.', 'unit_of_measurement_or_uom': '', 'unit_price': '498,125.00', 'quantity': '3', 'cgst_rate': 'None', 'cgst_amount': 'None', 'sgst_rate': 'None', 'sgst_amount': 'None', 'igst_rate': '', 'igst_amount': '24,907.50', 'taxable_amount_or_subtotal': '1,38,375.00', 'total_amount_or_gross_amount_of_the_item': '1,63,282.50'}]}}}
gpt_response = {'invoice_details': {'invoice_number': 'H01172/23-24', 'invoice_date': '17-Apr-23', 'invoice_due_date': '', 'order_id': 'NA', 'vendor_name': '1to1 Help.Net Pvt Ltd', 'buyer_name': 'Mr.Mandanna SC ( HR ) KPMG - BSR & Company LLP', 'shipto_name': '', 'bank_payment_terms': '45 Days'}, 'payment_details': {'account_number': '000205001864', 'vendor_ifsccode': 'ICIC0000002', 'vendor_bankname': 'ICICI Bank (India)'}, 'address_details': {'vendor_address': 'No.78, WeWork Salarpuria Sattva Magnificia 13B117, Tin Factory, No. 78, Dooravani nagar Swami Vivekananda Road, Next to KR Puram Bengaluru', 'vendor_city': 'Bengaluru', 'vendor_state': '', 'vendor_pincode': '', 'vendor_emailid': '', 'vendor_contactno': '8890094046', 'billto_address': 'Nesco, 7th Floor, IT Building No.3, Nesco IT Park, Nesco Complex, Goregaon (E) Mumbai - 400063', 'billto_city': 'Mumbai', 'billto_state': '', 'billto_pincode': '400063', 'billto_emailid': '', 'billto_contactno': '', 'shipto_address': ''}, 'amounts_and_tax': {'Subtotal_or_taxable_amount': '1,38,375.00', 'total_sgst_amount': '', 'total_cgst_amount': '', 'total_igst_amount': '24,907.50', 'total_amount_after_tax': '1,63,282.50', 'vendor_GSTIN': '27AAAFB9852F2ZE', 'shipto_GSTIN': '', 'billto_GSTIN': '', 'vendor_pan': 'AAAFB9852F'}, 'line_items': [{'s_no': '1', 'date_of_line_item': '', 'hsn_code': '998399', 'description': 'EAP Services From 01-Jan-23 to 31-Mar-23.', 'unit_of_measurement_or_uom': '', 'unit_price': '46,125.00', 'quantity': '3', 'cgst_rate': 'None', 'cgst_amount': 'None', 'sgst_rate': 'None', 'sgst_amount': 'None', 'igst_rate': '', 'igst_amount': '24,907.50', 'taxable_amount_or_subtotal': '1,38,375.00', 'total_amount_or_gross_amount_of_the_item': '1,63,282.50'}]}
ocr_text = "Current Account"
Now I want you to write a python code to swap the values of those perticular key which are given in gpt_response from data dictuonary if the value of ocr_text and ocr_text1 match
- Assistant
- User
make the given more generic there can be multiple file data in data dictionary and there can be more entities as well. So give me the revised code for it
- Assistant
- User
- Assistant
- User
there will be only one string at a time in ocr text and we have to do fuzz match. based on the fuzz match score will do the changes
- Assistant