Fix parsing (site changed)
This commit is contained in:
parent
359b91daf8
commit
391dc19666
1 changed files with 3 additions and 5 deletions
|
|
@ -62,18 +62,15 @@ class PdfPage():
|
||||||
page = txt.split('CONSOMMATION')[2].split('ACTIVITE DETAILLEE')[0]
|
page = txt.split('CONSOMMATION')[2].split('ACTIVITE DETAILLEE')[0]
|
||||||
lines = page.split('\n')
|
lines = page.split('\n')
|
||||||
lines = [x for x in lines if len(x) > 0] # Remove empty lines
|
lines = [x for x in lines if len(x) > 0] # Remove empty lines
|
||||||
numitems = ((len(lines) + 1) / 3) - 1 # Each line has three columns, remove one element (pictures)
|
|
||||||
lines.pop(0) # "MENSUELLE"
|
lines.pop(0) # "MENSUELLE"
|
||||||
lines.pop(0) # "Votre consommation au "
|
lines.pop(0) # "Votre consommation au "
|
||||||
details = []
|
details = []
|
||||||
first = True
|
detail = None
|
||||||
for line in lines:
|
for line in lines:
|
||||||
if re.match('[A-Za-z]', line[0]):
|
if re.match('[A-Za-z]', line[0]):
|
||||||
# We have a new element, return the other one
|
# We have a new element, return the other one
|
||||||
if not first:
|
if detail is not None:
|
||||||
details.append(detail)
|
details.append(detail)
|
||||||
else:
|
|
||||||
first = False
|
|
||||||
detail = Detail()
|
detail = Detail()
|
||||||
detail.price = Decimal(0)
|
detail.price = Decimal(0)
|
||||||
detail.infos = NotAvailable
|
detail.infos = NotAvailable
|
||||||
|
|
@ -110,6 +107,7 @@ class PdfPage():
|
||||||
lines = page.split('\n')
|
lines = page.split('\n')
|
||||||
lines = [x for x in lines if len(x) > 0] # Remove empty lines
|
lines = [x for x in lines if len(x) > 0] # Remove empty lines
|
||||||
numitems = (len(lines) + 1) / 5 # Each line has five columns
|
numitems = (len(lines) + 1) / 5 # Each line has five columns
|
||||||
|
lines.pop(0)
|
||||||
modif = 0
|
modif = 0
|
||||||
i = 0
|
i = 0
|
||||||
while i < numitems:
|
while i < numitems:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue