Ejemplo n.º 1
0
def veryfiOCR(filename: str):
    
    # authentication for Veryfi OCR API
    #below details can be found in Keys section in Veryfi account
    client_id = 'Client_id'
    client_secret = 'client_secret'
    username = '******'
    api_key = 'api_key'
    
    client = veryfi.Client(client_id, client_secret, username, api_key)
    
    # categories = ['Contractors', 'Utilities', 'Travel']
    # response = client.process_document(filename,categories=categories)
    
    response = client.process_document(filename)
    print(type(response))
    return response
Ejemplo n.º 2
0
import veryfi
import pprint

client_id = "vrfOHDDnOc7blOlPtYKiKI1b0pdGffjzjRrgXZJ"
client_secret = "BchJJyLYIoek2N86921MS2GvLJCgdtckox5yMjB3s796IDHODFtKSrGa4XP0nOLoP5my81fWhl51PD4lRbDof7awWtZNsAxfFo8CEn603eL5SI9YfwTDZDy2G7LX4p39"
username = "******"
api_key = "768fd6b5f23c7da36429610e691952b9"

client = veryfi.Client(client_id, client_secret, username, api_key)

file = open('extracted.txt', 'w+')
print('Starting Extarction.....')
print('processing file 1...')
categories = [
    'Invoice', 'Airfare', 'Travel', 'Lodging', 'Job Suplies and Materials',
    'Grocery'
]
json_result = client.process_document('Invoices/invoice.pdf', categories)
pprint.pprint(json_result)

file.write('===============Invoice 1===============\n')
file.write('Company Name: ' + str(json_result['vendor']['raw_name']) + '\n')
file.write('Invoice Number: ' + str(json_result['invoice_number']) + '\n')
file.write('Address: ' + str(json_result['vendor']['address']) + '\n')
file.write('Date: ' + str(json_result['date']) + '\n')
file.write('Customer: ' + str(json_result['bill_to_name']) + '\n')
file.write('Customer A/C#: ' + str(json_result['account_number']) + '\n')
file.write('Customer Address: ' + str(json_result['bill_to_address']) + '\n')
file.write('=========List Items=========\n')
for i in json_result['line_items']:
    file.write('sku: ' + str(i['sku']) + '\n')