diff --git a/app/forms.py b/app/forms.py index 9b9aed0..1ecae15 100644 --- a/app/forms.py +++ b/app/forms.py @@ -4,6 +4,7 @@ from wtforms import SelectField, SubmitField from wtforms.validators import DataRequired +# NOTE The choices should be shorter class DatasetForm(FlaskForm): dataset = SelectField(validators=[DataRequired()], choices=DATASETS) submit = SubmitField("Submit") diff --git a/app/preprocessing.py b/app/preprocessing.py index b600d3e..4fc633b 100644 --- a/app/preprocessing.py +++ b/app/preprocessing.py @@ -3,6 +3,7 @@ from json import load from pandas import DataFrame, json_normalize from constants import COLUMNS, FILES +from app.data_request import request_dataset def open_json(dataset) -> dict: @@ -18,6 +19,7 @@ def create_dataframe(dataset) -> DataFrame: """ Creates a DataFrame from a JSON file """ + request_dataset(dataset) json = open_json(dataset) df = json_normalize(data=json, record_path=["records"], errors="ignore",) filtered_df = df.filter(items=COLUMNS[dataset]) diff --git a/constants.py b/constants.py index 586634e..05e324f 100644 --- a/constants.py +++ b/constants.py @@ -2,12 +2,14 @@ DATASETS = [ "coronavirus-commercants-parisiens-livraison-a-domicile", "deconfinement-pistes-cyclables-temporaires", "deconfinement-parking-relais-doublement-des-places", + "deconfinement-rues-amenagees-pour-pietons", ] URL = "https://opendata.paris.fr/api/records/1.0/search/?dataset={}&q=&rows=-1" FILES = { "deconfinement-pistes-cyclables-temporaires": "data/cycling-paths.json", "deconfinement-parking-relais-doublement-des-places": "data/relay-parking.json", "coronavirus-commercants-parisiens-livraison-a-domicile": "data/home-delivery.json", + "deconfinement-rues-amenagees-pour-pietons": "data/pedestrian-streets.json", } COLUMNS = { "deconfinement-pistes-cyclables-temporaires": [ @@ -37,5 +39,12 @@ COLUMNS = { "fields.telephone", "fields.mail", ], + "deconfinement-rues-amenagees-pour-pietons": [ + "fields.geo_shape.coordinates", + "fields.nom_voie", + "fields.categorie", + "fields.statut", + "record_timestamp", + ], } SECRET_KEY = "trolaso"