Skip to content

Commit

Permalink
Merge branch 'master' of github.com:civicdataeu/parltrack
Browse files Browse the repository at this point in the history
  • Loading branch information
stf committed Dec 15, 2015
2 parents 5ed665f + 13320ef commit 5272711
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions parltrack/scrapers/findecl.py
Expand Up @@ -53,15 +53,23 @@ def parse_table(rows, threshold=3):
for row in rows[1:]:
if not row.strip():
if row_texts:
x_pos = max(len(l) for l in row_texts) - 1
cut_pos = x_pos = max(len(l) for l in row_texts) - 1
pos = -1

x_found = False
for row in row_texts:
if row.strip().endswith(' X'):
x_found = True
cut_pos = len(row[:-1].strip()) + 1
pos = 0
break

if x_pos > min(column_index.values()) - threshold:
row_text = ' '.join(x[:x_pos-1].strip() for x in row_texts)
if x_found:
row_text = ' '.join(x.strip()[:cut_pos] for x in row_texts)
else:
row_text = ' '.join(x.strip() for x in row_texts)

if len(row_text) > 5:
pos = -1
for i,v in column_index.items():
if x_pos <= v + threshold and x_pos >= v - threshold:
pos = i
Expand Down

0 comments on commit 5272711

Please sign in to comment.