-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat&fix(jsonParser): refactoring * feat(jsonParser): PDF to CSV * feat(data): CdL
- Loading branch information
Showing
26 changed files
with
9,733 additions
and
310 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import aspose.pdf as pdf | ||
import os | ||
import click | ||
from glob import glob | ||
|
||
@click.command() | ||
@click.option('--input', '-i', help='Input path with PDF files', required=True) | ||
def main(input:str): | ||
if not os.path.isdir(input): | ||
raise FileNotFoundError(f"'{input}' is not a folder or does not exist") | ||
folder = input | ||
folders = glob(f"{folder}/*.pdf") | ||
for file_pdf in folders: | ||
output_file = os.path.join(file_pdf.replace(".pdf", ".csv")) | ||
print(f"Converting {file_pdf} to {output_file}...") | ||
convert_PDF_to_CSV(file_pdf, output_file) | ||
|
||
def convert_PDF_to_CSV(infile:str, outfile:str): | ||
# Load input PDF document | ||
document = pdf.Document(infile) | ||
|
||
# Initialize the ExcelSaveOptions | ||
excelSaveOptions = pdf.ExcelSaveOptions() | ||
|
||
# Set CSV format | ||
excelSaveOptions.format= pdf.ExcelSaveOptions.ExcelFormat.CSV | ||
|
||
# Convert the PDF to Comma-Separated Values | ||
document.save(outfile, excelSaveOptions) | ||
|
||
print("Rendering process completed") | ||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
{ | ||
"schede": { | ||
"bianche": { | ||
"totali": 5, | ||
"seggio_n_telematico": 5 | ||
}, | ||
"nulle": { | ||
"totali": 0 | ||
}, | ||
"contestate": { | ||
"totali": 0 | ||
} | ||
}, | ||
"liste": [ | ||
{ | ||
"nome": "Beni Culturali Disum", | ||
"seggi": { | ||
"seggi_pieni": "9", | ||
"resti": "0,0", | ||
"seggi_ai_resti": "0", | ||
"seggi_totali": "9" | ||
}, | ||
"voti": { | ||
"totali": "127", | ||
"seggio_telematico": "127" | ||
} | ||
}, | ||
{ | ||
"totale": 127 | ||
} | ||
], | ||
"eletti": [ | ||
{ | ||
"nominativo": "SANFILIPPO Lorenzo", | ||
"lista": "Beni Culturali Disum", | ||
"voti": { | ||
"totali": 34, | ||
"seggio_telematico": 34 | ||
} | ||
}, | ||
{ | ||
"nominativo": "PETRALIA Salvatore Giuseppe", | ||
"lista": "Beni Culturali Disum", | ||
"voti": { | ||
"totali": 34, | ||
"seggio_telematico": 34 | ||
} | ||
}, | ||
{ | ||
"nominativo": "CUSUMANO Francesca Maria", | ||
"lista": "Beni Culturali Disum", | ||
"voti": { | ||
"totali": 13, | ||
"seggio_telematico": 13 | ||
} | ||
}, | ||
{ | ||
"nominativo": "CINO Anastasia", | ||
"lista": "Beni Culturali Disum", | ||
"voti": { | ||
"totali": 2, | ||
"seggio_telematico": 2 | ||
} | ||
}, | ||
{ | ||
"nominativo": "RUGGIERI Edith Maria Gae", | ||
"lista": "Beni Culturali Disum", | ||
"voti": { | ||
"totali": 5, | ||
"seggio_telematico": 5 | ||
} | ||
}, | ||
{ | ||
"nominativo": "DI STEFANO Agnese Pia", | ||
"lista": "Beni Culturali Disum", | ||
"voti": { | ||
"totali": 2, | ||
"seggio_telematico": 2 | ||
} | ||
}, | ||
{ | ||
"nominativo": "ASSENNATO Concetta Ambra", | ||
"lista": "Beni Culturali Disum", | ||
"voti": { | ||
"totali": 8, | ||
"seggio_telematico": 8 | ||
} | ||
}, | ||
{ | ||
"nominativo": "LO PIERO William", | ||
"lista": "Beni Culturali Disum", | ||
"voti": { | ||
"totali": 16, | ||
"seggio_telematico": 16 | ||
} | ||
}, | ||
{ | ||
"nominativo": "BENTIVEGNA Riccardo", | ||
"lista": "Beni Culturali Disum", | ||
"voti": { | ||
"totali": 9, | ||
"seggio_telematico": 9 | ||
} | ||
} | ||
], | ||
"non_eletti": [], | ||
"dipartimento": "BENI CULTURALI-L-1-Laurea Triennale (D.M.270/2004)", | ||
"seggi_da_assegnare": "9", | ||
"quoziente": 14.111, | ||
"votanti": { | ||
"totali": 132, | ||
"percentuale": 21.09, | ||
"seggio_n_telematico": 132 | ||
}, | ||
"elettori": { | ||
"totali": 626, | ||
"seggio_n_telematico": 626 | ||
} | ||
} |
Oops, something went wrong.