Add json export
This commit is contained in:
parent
e50eba313f
commit
d64b99f05e
3 changed files with 8 additions and 5 deletions
|
|
@ -1 +1,2 @@
|
||||||
pdf_url = "https://particulier.edf.fr/content/dam/2-Actifs/Documents/Offres/Grille_prix_Tarif_Bleu.pdf"
|
pdf_url = "https://particulier.edf.fr/content/dam/2-Actifs/Documents/Offres/Grille_prix_Tarif_Bleu.pdf"
|
||||||
|
json_location = "edf_bleu.json"
|
||||||
|
|
@ -7,5 +7,4 @@ from .edfpdf import PDFReader
|
||||||
def main():
|
def main():
|
||||||
config = tomllib.load(open("config.toml", "rb"))
|
config = tomllib.load(open("config.toml", "rb"))
|
||||||
pdf_reader = PDFReader(config["pdf_url"])
|
pdf_reader = PDFReader(config["pdf_url"])
|
||||||
|
pdf_reader.gen_json(config["json_location"])
|
||||||
pp(pdf_reader.tarifs)
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,9 @@
|
||||||
import io
|
import io
|
||||||
|
import json
|
||||||
import pypdf
|
import pypdf
|
||||||
import re
|
import re
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
from pprint import pprint as pp
|
|
||||||
|
|
||||||
|
|
||||||
class PDFReader:
|
class PDFReader:
|
||||||
def __init__(self, url):
|
def __init__(self, url):
|
||||||
|
|
@ -98,3 +97,7 @@ class PDFReader:
|
||||||
self.tarifs["tempo"] = tarifs
|
self.tarifs["tempo"] = tarifs
|
||||||
else:
|
else:
|
||||||
raise Exception("PDF text not available. Please call read_pdf() first.")
|
raise Exception("PDF text not available. Please call read_pdf() first.")
|
||||||
|
|
||||||
|
def gen_json(self, location):
|
||||||
|
with open(location, "w") as f:
|
||||||
|
json.dump(self.tarifs, f)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue