dvf/README.md

85 lines
3.1 KiB
Markdown
Raw Permalink Normal View History

2024-06-01 21:21:29 +00:00
# DVF
2024-06-01 21:23:47 +00:00
2024-06-01 23:30:12 +00:00
Il y a deux sources de données.
dvf et geodvf
geodvf contient sensiblement les mêmes données mais avec la latitude et la longitude.
## DVF
2024-06-01 21:21:29 +00:00
https://www.data.gouv.fr/fr/datasets/demandes-de-valeurs-foncieres/
2024-06-01 21:23:47 +00:00
2024-06-01 23:30:12 +00:00
mkdir -p dvf
2024-06-01 21:23:47 +00:00
curl -L https://www.data.gouv.fr/fr/datasets/r/78348f03-a11c-4a6b-b8db-2acf4fee81b1 -o dvf/2023.csv
curl -L https://www.data.gouv.fr/fr/datasets/r/87038926-fb31-4959-b2ae-7a24321c599a -o dvf/2022.csv
curl -L https://www.data.gouv.fr/fr/datasets/r/817204ac-2202-4b4a-98e7-4184d154d98c -o dvf/2021.csv
curl -L https://www.data.gouv.fr/fr/datasets/r/90a98de0-f562-4328-aa16-fe0dd1dca60f -o dvf/2020.csv
curl -L https://www.data.gouv.fr/fr/datasets/r/3004168d-bec4-44d9-a781-ef16f41856a2 -o dvf/2019.csv
2024-06-01 21:21:29 +00:00
2024-06-01 21:27:24 +00:00
Voila un sample des données parsées [dvf/sample.json](dvf/sample.json)
2024-06-01 23:30:12 +00:00
## GEODVF
2024-06-01 21:23:47 +00:00
2024-06-01 21:21:29 +00:00
https://files.data.gouv.fr/geo-dvf/latest/csv/
2024-06-01 21:23:47 +00:00
2024-06-01 23:30:12 +00:00
mkdir -p geodvf
2024-06-01 21:23:47 +00:00
curl https://files.data.gouv.fr/geo-dvf/latest/csv/2023/full.csv.gz -o geodvf/2023.csv.gz
curl https://files.data.gouv.fr/geo-dvf/latest/csv/2022/full.csv.gz -o geodvf/2022.csv.gz
curl https://files.data.gouv.fr/geo-dvf/latest/csv/2021/full.csv.gz -o geodvf/2021.csv.gz
curl https://files.data.gouv.fr/geo-dvf/latest/csv/2020/full.csv.gz -o geodvf/2020.csv.gz
curl https://files.data.gouv.fr/geo-dvf/latest/csv/2019/full.csv.gz -o geodvf/2019.csv.gz
2024-06-01 21:21:29 +00:00
2024-06-01 21:27:48 +00:00
Voila un sample des données parsées [geodvf/sample.json](geodvf/sample.json)
2024-06-01 21:27:24 +00:00
2024-06-01 21:21:29 +00:00
# run
2024-06-01 21:23:47 +00:00
2024-06-01 23:30:12 +00:00
Cette commande ouvre les fichiers csv et chie des inserts mysql en batch
echo "MYSQL=mysql://user:password@host/database?charset=utf8mb4&connectionLimit=10" > .env
2024-06-01 23:45:42 +00:00
node parse.js geodvf/2022.csv.gz | gzip > geodvf/2022.sql.gz
pv geodvf/2023.sql.gz | gunzip | mysql -u user -ppassword -h host database
2024-06-01 21:23:47 +00:00
2024-06-01 23:30:12 +00:00
```
CREATE TABLE IF NOT EXISTS dvf (
id_mutation VARCHAR(255),
date_mutation DATE,
numero_disposition VARCHAR(255),
nature_mutation VARCHAR(255),
valeur_fonciere DECIMAL(15, 2),
adresse_numero VARCHAR(255),
adresse_suffixe VARCHAR(255),
adresse_nom_voie VARCHAR(255),
adresse_code_voie VARCHAR(255),
code_postal VARCHAR(255),
code_commune VARCHAR(255),
nom_commune VARCHAR(255),
code_departement VARCHAR(255),
ancien_code_commune VARCHAR(255),
ancien_nom_commune VARCHAR(255),
id_parcelle VARCHAR(255),
ancien_id_parcelle VARCHAR(255),
numero_volume VARCHAR(255),
lot1_numero VARCHAR(255),
lot1_surface_carrez DECIMAL(15, 2),
lot2_numero VARCHAR(255),
lot2_surface_carrez DECIMAL(15, 2),
lot3_numero VARCHAR(255),
lot3_surface_carrez DECIMAL(15, 2),
lot4_numero VARCHAR(255),
lot4_surface_carrez DECIMAL(15, 2),
lot5_numero VARCHAR(255),
lot5_surface_carrez DECIMAL(15, 2),
nombre_lots INT,
code_type_local VARCHAR(255),
type_local VARCHAR(255),
surface_reelle_bati DECIMAL(15, 2),
nombre_pieces_principales INT,
code_nature_culture VARCHAR(255),
nature_culture VARCHAR(255),
code_nature_culture_speciale VARCHAR(255),
nature_culture_speciale VARCHAR(255),
surface_terrain DECIMAL(15, 2),
longitude DECIMAL(10, 6),
latitude DECIMAL(10, 6)
);
```