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"
|
||||
json_location = "edf_bleu.json"
|
||||
|
|
@ -7,5 +7,4 @@ from .edfpdf import PDFReader
|
|||
def main():
|
||||
config = tomllib.load(open("config.toml", "rb"))
|
||||
pdf_reader = PDFReader(config["pdf_url"])
|
||||
|
||||
pp(pdf_reader.tarifs)
|
||||
pdf_reader.gen_json(config["json_location"])
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
import io
|
||||
import json
|
||||
import pypdf
|
||||
import re
|
||||
import requests
|
||||
|
||||
from pprint import pprint as pp
|
||||
|
||||
|
||||
class PDFReader:
|
||||
def __init__(self, url):
|
||||
|
|
@ -98,3 +97,7 @@ class PDFReader:
|
|||
self.tarifs["tempo"] = tarifs
|
||||
else:
|
||||
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