Last active
September 8, 2017 12:57
-
-
Save GuillaumePressiat/2c4e2db031d666f755742ec9fbf6e9d0 to your computer and use it in GitHub Desktop.
Découper le fichier Etalab Finess géocodé de data.gouv.fr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# Le fichier est dispo ici : https://www.data.gouv.fr/fr/datasets/finess-extraction-du-fichier-des-etablissements/ | |
import os | |
os.chdir('..\\..\\') | |
print ('----------------- Découper Géocodage et structureET Etalab ---------------') | |
filin = open('data\\etalab_geolocalise\\etalab_cs1100507_stock_20170801-0442.csv') | |
filout = open('data\\etalab_geolocalise\\structureet_20170801', 'w') | |
with filin as infile: | |
for line in infile: | |
if line[0:11] == 'structureet': | |
# Suppression des = à la réécriture | |
filout.write(line[12:].replace("=\"", "\"")) | |
filout.close() | |
filin = open('data\\etalab_geolocalise\\etalab_cs1100507_stock_20170801-0442.csv') | |
filout = open('data\\etalab_geolocalise\\geolocalisation_20170801', 'w') | |
with filin as infile: | |
for line in infile: | |
if line[0:15] == 'geolocalisation': | |
# Remplacer les , par des ; dans la partie géocodage et supprimer les = | |
filout.write(line[16:].replace(",", ";").replace("=\"", "\"")) | |
filout.close() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment