Fix parsing history
Site changed
This commit is contained in:
parent
65c52d9982
commit
93448c3910
1 changed files with 15 additions and 4 deletions
|
|
@ -55,13 +55,12 @@ class PdfPage():
|
||||||
os.remove(temptxt)
|
os.remove(temptxt)
|
||||||
return txt
|
return txt
|
||||||
|
|
||||||
|
|
||||||
def get_details(self):
|
def get_details(self):
|
||||||
txt = self._parse_pdf()
|
txt = self._parse_pdf()
|
||||||
page = txt.split('CONSOMMATION MENSUELLE')[1].split('ACTIVITE DETAILLEE')[0]
|
page = txt.split('CONSOMMATION MENSUELLE')[1].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 # Each line has three columns
|
numitems = ((len(lines) + 1) / 3) - 1 # Each line has three columns, remove one element (pictures)
|
||||||
lines.insert(len(lines) - 1, '') # Add an empty column for "Prélèvement mensuel
|
lines.insert(len(lines) - 1, '') # Add an empty column for "Prélèvement mensuel
|
||||||
lines.pop(0)
|
lines.pop(0)
|
||||||
details = []
|
details = []
|
||||||
|
|
@ -105,13 +104,24 @@ 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
|
||||||
for i in range(numitems):
|
modif = 0
|
||||||
nature = i * 5
|
i = 0
|
||||||
|
while i < numitems:
|
||||||
|
if modif > 0:
|
||||||
|
numitems = ((len(lines) + 1 + modif) / 5)
|
||||||
|
nature = i * 5 - modif
|
||||||
dateop = nature + 1
|
dateop = nature + 1
|
||||||
corres = dateop + 1
|
corres = dateop + 1
|
||||||
duree = corres + 1
|
duree = corres + 1
|
||||||
price = duree + 1
|
price = duree + 1
|
||||||
|
|
||||||
|
if "Changement vers le Forfait" in lines[nature]:
|
||||||
|
modif += 1
|
||||||
|
i += 1
|
||||||
|
continue
|
||||||
|
|
||||||
|
if not lines[corres][0:3].isdigit() and not lines[corres][0:3] == "-":
|
||||||
|
modif += 1
|
||||||
detail = Detail()
|
detail = Detail()
|
||||||
mydate = date(*reversed([int(x) for x in lines[dateop].split(' ')[0].split("/")]))
|
mydate = date(*reversed([int(x) for x in lines[dateop].split(' ')[0].split("/")]))
|
||||||
mytime = time(*[int(x) for x in lines[dateop].split(' ')[1].split(":")])
|
mytime = time(*[int(x) for x in lines[dateop].split(' ')[1].split(":")])
|
||||||
|
|
@ -130,6 +140,7 @@ class PdfPage():
|
||||||
detail.price = Decimal(0)
|
detail.price = Decimal(0)
|
||||||
|
|
||||||
details.append(detail)
|
details.append(detail)
|
||||||
|
i += 1
|
||||||
return sorted(details, key=_get_date, reverse=True)
|
return sorted(details, key=_get_date, reverse=True)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue