Skip to content

Instantly share code, notes, and snippets.

@mquandalle
Last active December 12, 2021 19:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mquandalle/fce85527ddc3279712b5a6d864b67204 to your computer and use it in GitHub Desktop.
Save mquandalle/fce85527ddc3279712b5a6d864b67204 to your computer and use it in GitHub Desktop.
Differences entres les fichiers Etalab et La Poste pour les données de codes postaux
const communesEtalab = await (
await fetch('https://unpkg.com/@etalab/decoupage-administratif@0.9.0-0/data/communes.json')
).json();
const laPosteCSV = await fetch(
'https://www.data.gouv.fr/fr/datasets/r/554590ab-ae62-40ac-8353-ee75162c05ee'
);
const communesLaPoste = (await laPosteCSV.text()).split('\n').reduce((acc, line) => {
const [codeInsee, , codePostal] = line.split(';');
acc[codeInsee] = (acc[codeInsee] ?? []).concat(codePostal);
return acc;
}, {});
console.log('Code Insee | Nom | CP La Poste | CP Etalab');
console.log('---------- | --- | ----------- | ---------');
communesEtalab
.filter((c) => c.codesPostaux?.length >= 2)
.map((c) => ({
codeInsee: c.code,
nom: c.nom,
cpEtalab: c.codesPostaux,
cpLaPoste: [...new Set(communesLaPoste[c.code] ?? [])]
}))
.filter((c) => [...c.cpEtalab].sort().join() !== [...c.cpLaPoste].sort().join())
.forEach((c) =>
console.log(`${c.codeInsee} | ${c.nom} | ${c.cpLaPoste.join(', ')} | ${c.cpEtalab.join(', ')}`)
);
Code Insee Nom CP La Poste CP Etalab
03151 Louroux-de-Beaune 03600 03600, 03170
03191 Murat 03390 03390, 03430
03256 Saint-Priest-en-Murat 03390 03390, 03170
07018 Astet 07330 07330, 07660, 07510, 07590
07024 Banne 07460 07460, 07140
07029 Beaumont 07110 07110, 07260
07079 Désaignes 07570 07570, 07320
07084 Eclassan 07370 07370, 07300, 07290
07103 Saint-Julien-d'Intres 07310, 07320 07310, 07320, 07160
07114 Labatie-d'Andaure 07570 07570, 07270
07137 Lavillatte 07660 07660, 07470
07140 Lemps 07610 07610, 07300
07154 Mazan-l'Abbaye 07510 07510, 07660
07167 Les Ollières-sur-Eyrieux 07360 07360, 07190
07184 Pranles 07000 07000, 07190
07254 Saint-Julien-du-Serre 07200 07200, 07600
07274 Saint-Maurice-en-Chalencon 07190 07190, 07240, 07360
07277 Saint-Michel-de-Boulogne 07200 07200, 07000
07278 Saint-Michel-de-Chabrillanoux 07360 07360, 07190, 07240
07321 Thorrenc 07340 07340, 07100
08363 Revin 08500 08500, 08800
08367 Rocroi 08230 08230, 08500
08449 Thin-le-Moutier 08460 08460, 08090, 08430
09033 Bagert 09230 09230, 09160
09074 Camon 09500 09500, 09600
09107 Dun 09600 09600, 09120
09118 Esplas-de-Sérou 09420 09420, 09240
09126 Freychenet 09300 09300, 09000
09177 Madière 09100 09100, 09130
09256 Saint-Bauzeil 09120 09120, 09100
09269 Saint-Martin-de-Caralp 09000 09000, 09240
09274 Saint-Quentin-la-Tour 09500 09500, 09600
09276 Saint-Victor-Rouzaud 09100 09100, 09120
09331 Le Vernet 09700 09700, 09100
12011 Arvieu 12120 12120, 12410
12013 Aubin 12110 12110, 12300
12016 Auzits 12390 12390, 12110
12027 Bessuéjouls 12500 12500, 12340, 12190
12033 Bozouls 12340 12340, 12500, 12190
12035 Brasc 12550 12550, 12170
12043 Calmont 12450 12450, 12120
12064 Le Cayrol 12500 12500, 12210
12066 Clairvaux-d'Aveyron 12330 12330, 12390
12067 Le Clapier 12540 12540, 34260
12069 Combret 12370 12370, 12380
12070 Compeyre 12520 12520, 12640
12079 Coubisou 12190 12190, 12210, 12500
12097 Espeyrac 12140 12140, 12320
12100 Firmi 12300 12300, 12110
12110 Golinhac 12140 12140, 12580
12125 Laval-Roquecezière 12380 12380, 12370
12129 Lestrade-et-Thouels 12430 12430, 12480
12136 Maleville 12350 12350, 12260
12145 Millau 12100 12100, 12720
12149 Montclar 12550 12550, 12480
12157 Montrozier 12630 12630, 12740
12161 Mouret 12330 12330, 12580, 12320
12165 Muret-le-Château 12330 12330, 12580
12167 Najac 12270 12270, 82160, 82330
12168 Nant 12230 12230, 30750
12171 Nauviale 12330 12330, 12320
12172 Le Nayrac 12190 12190, 12140
12174 Olemps 12510 12510, 12000
12197 Réquista 12170 12170, 12550
12201 Rodelle 12340 12340, 12190
12204 La Roque-Sainte-Marguerite 12100 12100, 12720
12206 Roussennac 12220 12220, 12390
12214 Saint-Chély-d'Aubrac 12470 12470, 12500
12224 Saint Geniez d'Olt et d'Aubrac 12130 12130, 12470
12226 Saint-Hippolyte 12140 12140, 12600
12231 Saint-Jean-du-Bruel 12230 12230, 30750
12233 Saint-Juéry 12550 12550, 12380
12237 Saint-Laurent-d'Olt 12560 12560, 48500
12241 Sainte-Radegonde 12850 12850, 12450
12270 Sévérac d'Aveyron 12150 12150, 12640, 12720
12272 Sonnac 12700 12700, 12220
12280 Thérondels 12600 12600, 15230
12291 Verrières 12520 12520, 12780, 12640, 12150
12298 Villecomtal 12580 12580, 12330, 12340
12299 Villefranche-de-Panat 12430 12430, 12480
12307 Curan 12410 12410, 12620
13001 Aix-en-Provence 13290, 13080, 13540, 13090, 13100 13090, 13100, 13290, 13080, 13540, 13122
13004 Arles 13104, 13123, 13129, 13200, 13280 13104, 13129, 13200, 13280, 13123, 13270
13005 Aubagne 13400 13400, 13470
13007 Auriol 13390 13390, 13112
13047 Istres 13118, 13800 13800, 13118, 13140, 13128
13055 Marseille 13001, 13002, 13003, 13004, 13005, 13006, 13007, 13008, 13009, 13010, 13011, 13012, 13013, 13014, 13015, 13016
13204 Marseille 4e Arrondissement 13004 13004, 13005
13206 Marseille 6e Arrondissement 13006 13006, 13007
13210 Marseille 10e Arrondissement 13010 13010, 13011
13211 Marseille 11e Arrondissement 13011 13011, 13010, 13012
13212 Marseille 12e Arrondissement 13012 13012, 13013, 13004
13213 Marseille 13e Arrondissement 13013 13013, 13012
13214 Marseille 14e Arrondissement 13014 13014, 13013
13215 Marseille 15e Arrondissement 13015 13015, 13016
14712 Troarn 14670 14670, 14940
15002 Alleuze 15100 15100, 15260
15005 Anglards-de-Saint-Flour 15100 15100, 15320
15012 Arpajon-sur-Cère 15130 15130, 15000
15043 Charmensac 15500 15500, 15170
15051 Clavières 15320 15320, 43300
15103 Leucamp 15120 15120, 15130
15185 Saint-Étienne-de-Chomeil 15400 15400, 15270
15215 Saint-Simon 15130 15130, 15000
15241 La Trinitat 15110 15110, 12210
15267 Ytrac 15000, 15130 15000, 15130, 15250
17052 Boisredon 17150 17150, 17130
17179 Les Gonds 17100 17100, 17136, 17460
17299 Rochefort 17300 17300, 17134, 17135, 17133
17308 Saint-Agnant 17620 17133, 17620
18018 Avord 18520 18520, 18490
18160 Nérondes 18350 18350, 18800
18213 Saint-Germain-du-Puy 18390 18390, 18000
27140 Chambray 27120 27120, 27950
27536 Saint-Éloi-de-Fourques 27800 27800, 27520
28219 Luigny 28480 28480, 28160
29019 Brest 29200 29200, 29000, 29240
2A004 Ajaccio 20000, 20090, 20167 20167, 20000, 20090, 20129, 20166
2A041 Bonifacio 20169 20169, 20146
2A085 Cauro 20117 20166, 20117
2A092 Conca 20135 20144, 20135
2A104 Eccica-Suarella 20117 20117, 20166
2A114 Figari 20114 20114, 20146, 20131
2A130 Grosseto-Prugna 20128, 20166 20166, 20117, 20128
2A139 Lecci 20137 20137, 20000, 20144
2A142 Levie 20170 20170, 20100
2A249 Propriano 20110 20110, 20100
2A269 Sari-Solenzara 20145 20145, 20144
2A300 San-Gavino-di-Carbini 20170 20137, 20170
2A345 Vero 20172 20172, 20133
2A362 Zonza 20144, 20124 20144, 20124, 20170
2B121 Galéria 20245 20245, 20260
2B126 Giuncaggio 20251 20251, 20270
2B229 Pietroso 20242 20242, 20240
30006 Aimargues 30470 30470, 30220
30008 Allègre-les-Fumades 30500 30500, 30340
30075 Caveirac 30820 30820, 30900
30189 Nîmes 30900, 30000 30000, 30998, 30900
30258 Saint-Gilles 30800 30800, 30998
30284 Saint-Martin-de-Valgalgues 30520 30520, 30100
30341 Vauvert 30600 30600, 30640
31555 Toulouse 31300, 31500, 31000, 31100, 31200, 31400 31500, 31100, 31400, 31300, 31000, 31200, 31998
33063 Bordeaux 33000, 33100, 33200, 33300, 33800 33000, 33300, 33100, 33090, 33800, 33200
33281 Mérignac 33700 33700, 33693
33318 Pessac 33600 33600, 33400
33529 La Teste-de-Buch 33260, 33115 33260, 33115, 33164
34101 Florensac 34510 34510, 34110, 34550
34154 Mauguio 34130 34280, 34130
34172 Montpellier 34090, 34000, 34070, 34080 34000, 34080, 34090, 34070, 34295
34186 Octon 34800 34800, 34650
34287 Saint-Saturnin-de-Lucian 34725 34725, 34700
34336 Villeneuve-lès-Béziers 34420, 34500 34420, 34220, 34500
37071 Chezelles 37220 37220, 37120
37205 Saché 37190 37190, 37260
38126 Corenc 38700 38700, 38240
38185 Grenoble 38000, 38100 38000, 38100, 38700
38191 Huez 38750 38750, 38520
38279 Notre-Dame-de-Mésage 38220 38220, 38560
38448 Saint-Prim 38370 38370, 38121
38485 Seyssinet-Pariset 38170 38170, 38180
39099 Champdivers 39500 39500, 39120
39426 Plasne 39210, 39800 39800, 39210, 39220
39510 Septmoncel les Molunes 39310 39310, 39200
42286 Saint-Romain-les-Atheux 42660 42660, 42500
43039 Le Brignon 43370 43370, 43150
43053 Champclause 43430, 43260 43430, 43260, 43000
43157 Le Puy-en-Velay 43000 43000, 43750
43211 Saint-Maurice-de-Lignon 43200 43200, 43120
43251 Vals-près-le-Puy 43750 43750, 43000
48009 Peyre en Aubrac 48130 48130, 48100
48063 Fontans 48700 48700, 48120
48085 Laval-du-Tarn 48500 48500, 48210
48175 Saint-Pierre-de-Nogaret 48340 48340, 48500
50099 Carentan-les-Marais 50480, 50500, 50620 50500, 50480
50531 Saint-Ovin 50300 50300, 50220
51253 Florent-en-Argonne 51800 51800, 55120
51507 Sainte-Menehould 51800 51800, 55120
54215 Frouard 54390 54390, 54250
54405 Ochey 54170 54170, 54201
54463 Rosières-en-Haye 54385 54207, 54385
54490 Saizerais 54380 54380, 54460
57028 Argancy 57640 57640, 57140
57463 Metz 57000, 57050, 57070 57000, 57050, 57070, 57140
57511 Norroy-le-Veneur 57140 57140, 57855
57607 Sainte-Barbe 57640 57640, 57530
59027 Aubry-du-Hainaut 59494 59494, 59590
59294 Haynecourt 59268 59268, 59341
59491 Raismes 59590 59590, 59278, 59860, 59135
59507 Ronchin 59790 59790, 59000
60034 Avrechy 60130 60130, 60600
60122 Campeaux 60220 60220, 60380
60282 Gouvieux 60270 60500, 60270, 60260, 60740
60448 Neufchelles 60890 60890, 60620
60523 Rainvillers 60155 60155, 60390, 60650
60681 Villers-Saint-Barthélemy 60650 60390, 60650
64445 Pau 64000 64000, 64023
67088 Dehlingen 67430 67430, 57410, 57412
67169 Gries 67240 67500, 67240
67180 Haguenau 67500 67500, 67580, 67240, 67620, 67360, 67660, 67350, 67250, 67590
67377 Plaine 67420 67420, 67130
68097 Fréland 68240 68240, 68150
68149 Huningue 68330 68330, 68300
68237 Niedermorschwihr 68230 68230, 68410
68338 Turckheim 68230 68230, 68910, 68410
69123 Lyon 69001, 69002, 69003, 69004, 69005, 69006, 69007, 69008, 69009
69291 Saint-Symphorien-d'Ozon 69360 69360, 69320, 69960
70318 Magny-Danigon 70200 70200, 70250
70328 Malbouhans 70200 70200, 70270
71016 Azé 71260 71260, 71960
71278 Marigny 71300 71300, 71460, 71210
71339 Ozolles 71120 71120, 71800
71447 Saint-Mard-de-Vaux 71640 71640, 71510
71509 La Celle-en-Morvan 71400 71400, 71550
73088 Cohennoz 73400, 73590 73590, 73400, 73200
73227 Courchevel 73120 73120, 73600
74208 Passy 74190 74480, 74790, 74190, 74310, 74700, 74170
75056 Paris 75001, 75002, 75003, 75004, 75005, 75006, 75007, 75008, 75009, 75010, 75011, 75012, 75013, 75014, 75015, 75016, 75017, 75018, 75019, 75020
76108 Bois-Guillaume 76230 76230, 76420
76231 Elbeuf 76500 76500, 27370, 76410
76474 Notre-Dame-de-Bondeville 76960 76960, 76130
76540 Rouen 76000, 76100 76000, 76100, 76600
76545 Rouxmesnil-Bouteilles 76370 76370, 76200, 76550
78015 Andrésy 78570 78570, 78260, 78780
78090 Bouafle 78410 78410, 78130
78123 Carrières-sous-Poissy 78955 78955, 78570
78146 Chatou 78400 78400, 78110
78334 Lévis-Saint-Nom 78320 78320, 78690
78502 Le Port-Marly 78560 78560, 78380
78551 Saint-Germain-en-Laye 78100, 78112 78100, 78260, 78600, 78700, 78300, 78240
78640 Vélizy-Villacoublay 78140 78140, 78129
78650 Le Vésinet 78110 78110, 78400
78674 Villepreux 78450 78450, 78590
81034 Boissezon 81490 81490, 81100
81036 Bout-du-Pont-de-Larn 81660 81660, 81200
81048 Cagnac-les-Mines 81130 81130, 81400
81101 Le Garric 81450 81450, 81400
81103 Gijounet 81530 81530, 81230
81130 Lagarrigue 81090 81090, 81290
81144 Lescure-d'Albigeois 81380 81380, 81000
81145 Lisle-sur-Tarn 81310 81310, 81800
81202 Parisot 81310 81310, 81800
81231 Rouairoux 81240 81240, 81200
81285 Sérénac 81350 81350, 81000
83058 Flayosc 83780 83780, 83510
83082 Montferrat 83131 83131, 83998
83107 Roquebrune-sur-Argens 83380, 83520 83520, 83380, 83370
83137 Toulon 83100, 83200, 83000 83000, 83100, 83200, 83800
86085 Coussay 86110 86110, 86420, 86140
86197 Pouant 86200 86200, 37120
86211 Romagne 86700 86700, 86400
86225 Saint-Jean-de-Sauves 86330 86330, 86110
86281 Saint-Martin-la-Pallu 86380, 86110, 86170 86380, 86170
88492 Le Valtin 88230 88230, 88400
92012 Boulogne-Billancourt 92100 92100, 75016
92023 Clamart 92140 92140, 92190
92040 Issy-les-Moulineaux 92130 92130, 75015
94068 Saint-Maur-des-Fossés 94100, 94210 94100, 94210, 94340
95127 Cergy 95800, 95000 95000, 95800, 95520
95428 Montmorency 95160 95160, 95330
95500 Pontoise 95000, 95300 95000, 95300, 95520
97209 Fort-de-France 97200, 97234 97200, 97234, 97212
97408 La Possession 97419 97419, 97433
97415 Saint-Paul 97422, 97460, 97435, 97423, 97434, 97411 97434, 97422, 97460, 97411, 97435, 97423, 97419, 97433
97416 Saint-Pierre 97410, 97432 97432, 97410, 97430
97422 Le Tampon 97418, 97430 97418, 97430, 97432
deno run --allow-net https://gist.githubusercontent.com/mquandalle/fce85527ddc3279712b5a6d864b67204/raw/a5929edc58b616b0fc56dd670a113ebf98acdded/diff-codepostaux.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment