This is obtained from upstream and ADDITIONALLY changes the try: val = int(row[i]) in upstream int3l@github's version to int(float(row[i])). -- Matthias Andree, mandree@FreeBSD.org From 06e7f8077467950d2f4e0f619fb193730c2d2079 Mon Sep 17 00:00:00 2001 From: int3l Date: Thu, 27 Jan 2022 16:09:21 +0200 Subject: [PATCH] Fix confidence conversion from str to int Account for negative values. Fixes #406 --- pytesseract/pytesseract.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pytesseract/pytesseract.py b/pytesseract/pytesseract.py index 984b106..e927e80 100644 --- a/pytesseract/pytesseract.py +++ b/pytesseract/pytesseract.py @@ -313,9 +313,14 @@ def file_to_dict(tsv, cell_delimiter, str_col_idx): if len(row) <= i: continue - val = row[i] - if row[i].isdigit() and i != str_col_idx: - val = int(row[i]) + if i != str_col_idx: + try: + val = int(float(row[i])) + except ValueError: + val = row[i] + else: + val = row[i] + result[head].append(val) return result