import boto3 from trp import Document # Document documentName = "expense.png" # Amazon Textract client textract = boto3.client('textract') # Call Amazon Textract with open(documentName, "rb") as document: response = textract.analyze_document( Document={ 'Bytes': document.read(), }, FeatureTypes=["TABLES"]) #print(response) doc = Document(response) def isFloat(input): try: float(input) except ValueError: return False return True warning = "" for page in doc.pages: # Print tables for table in page.tables: for r, row in enumerate(table.rows): itemName = "" for c, cell in enumerate(row.cells): print("Table[{}][{}] = {}".format(r, c, cell.text)) if(c == 0): itemName = cell.text elif(c == 4 and isFloat(cell.text)): value = float(cell.text) if(value > 1000): warning += "{} is greater than $1000.".format(itemName) if(warning): print("\nReview needed:\n====================\n" + warning)