85 lines
		
	
	
		
			3.1 KiB
		
	
	
	
		
			Markdown
		
	
	
	
	
	
			
		
		
	
	
			85 lines
		
	
	
		
			3.1 KiB
		
	
	
	
		
			Markdown
		
	
	
	
	
	
# DVF
 | 
						|
 | 
						|
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
 | 
						|
 | 
						|
https://www.data.gouv.fr/fr/datasets/demandes-de-valeurs-foncieres/
 | 
						|
 | 
						|
    mkdir -p dvf
 | 
						|
    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
 | 
						|
 | 
						|
Voila un sample des données parsées [dvf/sample.json](dvf/sample.json)
 | 
						|
 | 
						|
## GEODVF
 | 
						|
 | 
						|
https://files.data.gouv.fr/geo-dvf/latest/csv/
 | 
						|
 | 
						|
    mkdir -p geodvf
 | 
						|
    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
 | 
						|
 | 
						|
Voila un sample des données parsées [geodvf/sample.json](geodvf/sample.json)
 | 
						|
 | 
						|
# run
 | 
						|
 | 
						|
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
 | 
						|
    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
 | 
						|
 | 
						|
```
 | 
						|
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)
 | 
						|
);
 | 
						|
```
 |