Add pedestrian streets dataset
This commit is contained in:
parent
4f5013460f
commit
ffe9009d1b
|
@ -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")
|
||||
|
|
|
@ -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])
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue