From 73e52939f5d295f521e4ba4846f5b3c3e36367c5 Mon Sep 17 00:00:00 2001 From: Vinayak Mehta Date: Wed, 5 Sep 2018 18:50:10 +0530 Subject: [PATCH] Add parsing_report property --- camelot/core.py | 19 +++++++++++++++++++ camelot/parsers.py | 4 ++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/camelot/core.py b/camelot/core.py index 9089593..0c66d7a 100644 --- a/camelot/core.py +++ b/camelot/core.py @@ -1,3 +1,5 @@ +import json + import numpy as np @@ -277,6 +279,17 @@ class Table(object): def page(self, p): self._page = p + @property + def parsing_report(self): + # pretty? + report = { + 'accuracy': self._accuracy, + 'whitespace': self._whitespace, + 'order': self._order, + 'page': self._page + } + return report + class TableList(list): def __init__(self, tables): @@ -286,6 +299,12 @@ class TableList(list): return '<{} tables={}>'.format( self.__class__.__name__, len(self._tables)) + def __len__(self): + return len(self._tables) + + def __getitem__(self, idx): + return self._tables[idx] + class Geometry(object): def __init__(self): diff --git a/camelot/parsers.py b/camelot/parsers.py index 20820da..50bd8a5 100644 --- a/camelot/parsers.py +++ b/camelot/parsers.py @@ -257,7 +257,7 @@ class Stream: table.accuracy = accuracy table.whitespace = whitespace table.order = table_no + 1 - table.page = os.path.basename(bname).replace('page-', '') + table.page = int(os.path.basename(bname).replace('page-', '')) _tables.append(table) @@ -462,7 +462,7 @@ class Lattice: table.accuracy = accuracy table.whitespace = whitespace table.order = table_no + 1 - table.page = os.path.basename(bname).replace('page-', '') + table.page = int(os.path.basename(bname).replace('page-', '')) _tables.append(table)