Remove FILENAMES constant

This commit is contained in:
coolneng 2020-06-10 21:49:58 +02:00
parent 3e811338c4
commit 7044dda659
Signed by: coolneng
GPG Key ID: 9893DA236405AF57
3 changed files with 30 additions and 35 deletions

View File

@ -4,42 +4,38 @@ DATASETS = [
"deconfinement-parking-relais-doublement-des-places",
]
URL = "https://opendata.paris.fr/api/records/1.0/search/?dataset={}&q=&rows=-1"
FILENAMES = {
"coronavirus-commercants-parisiens-livraison-a-domicile": "home-delivery",
"deconfinement-pistes-cyclables-temporaires": "cycling-paths",
"deconfinement-parking-relais-doublement-des-places": "relay-parking",
}
TEST_URL = "https://opendata.paris.fr/api/records/1.0/search/?dataset=deconfinement-pistes-cyclables-temporaires&rows=-1"
FILES = {
"cycling-paths": "data/cycling-paths.json",
"relay-parking": "data/relay-parking.json",
"home-delivery": "data/home-delivery.json",
"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",
}
COLUMNS = {
"cycling-paths": [
["fields", "geo_shape", "coordinates"],
"statut",
"deconfinement-pistes-cyclables-temporaires": [
"fields.geo_shape.coordinates",
"fields.statut",
"record_timestamp",
"complement",
"fields.complement",
],
"relay-parking": [
"societe",
"nb_places_dispositif_environ",
"parcs",
"geo_shape",
"cp",
"ville",
"adresse",
"deconfinement-parking-relais-doublement-des-places": [
"fields.societe",
"fields.nb_places_dispositif_environ",
"fields.parcs",
"fields.geo_shape.coordinates",
"fields.cp",
"fields.ville",
"fields.adresse",
],
"home-delivery": [
"geo_shape",
"adresse",
"code_postal",
"nom_du_commerce",
"type_du_commerce",
"site_internet",
"coronavirus-commercants-parisiens-livraison-a-domicile": [
"fields.geo_shape.coordinates",
"fields.adresse",
"fields.code_postal",
"fields.nom_du_commerce",
"fields.type_de_commerce",
"fields.site_internet",
"record_timestamp",
"precisions",
"telephone",
"mail",
"fields.precisions",
"fields.telephone",
"fields.mail",
],
}

View File

@ -1,6 +1,6 @@
from json import load
from pandas import json_normalize, DataFrame, set_option
from constants import FILES, COLUMNS
from pandas import json_normalize, DataFrame
from .constants import FILES, COLUMNS
def open_json(dataset) -> dict:

View File

@ -1,6 +1,6 @@
from json import dump
from requests import get
from constants import FILENAMES, URL
from .constants import FILES, URL
def format_url(dataset) -> str:
@ -15,8 +15,7 @@ def save_json(data, dataset):
"""
Dumps the data into a JSON file
"""
data_dir = "data/"
with open(data_dir + FILENAMES[dataset] + ".json", "w") as f:
with open(FILES[dataset], "w") as f:
dump(data, f, ensure_ascii=False)