diff --git a/camelot/parsers/lattice.py b/camelot/parsers/lattice.py index cca6789..14430c8 100644 --- a/camelot/parsers/lattice.py +++ b/camelot/parsers/lattice.py @@ -273,8 +273,8 @@ class Lattice(BaseParser): t_bbox['vertical'] = text_in_bbox(tk, self.vertical_text) self.t_bbox = t_bbox - for direction in t_bbox: - t_bbox[direction].sort(key=lambda x: (-x.y0, x.x0)) + for direction in self.t_bbox: + self.t_bbox[direction].sort(key=lambda x: (x.x0, -x.y0)) cols, rows = zip(*self.table_bbox[tk]) cols, rows = list(cols), list(rows) diff --git a/camelot/parsers/stream.py b/camelot/parsers/stream.py index 0fbae71..d9481cc 100644 --- a/camelot/parsers/stream.py +++ b/camelot/parsers/stream.py @@ -296,7 +296,7 @@ class Stream(BaseParser): self.t_bbox = t_bbox for direction in self.t_bbox: - self.t_bbox[direction].sort(key=lambda x: (-x.y0, x.x0)) + self.t_bbox[direction].sort(key=lambda x: (x.x0, -x.y0)) text_x_min, text_y_min, text_x_max, text_y_max = self._text_bbox(self.t_bbox) rows_grouped = self._group_rows(self.t_bbox['horizontal'], row_close_tol=self.row_close_tol)