Données ouvertes historisées et Python David Larlet — https://larlet.fr/david/ Des données aux communs David Larlet — https://larlet.fr/david/ Suite de Confoo 2016 https://larlet.fr/david/blog/2 016/opendata-liens-casses/ David Larlet — https://larlet.fr/david/ Python David Larlet — https://larlet.fr/david/ ? OpenData David Larlet — https://larlet.fr/david/ ? 1. Données ouvertes → publication David Larlet — https://larlet.fr/david/ https://www.data.gouv.fr/fr/ 2. Données exploitables → suggestion David Larlet — https://larlet.fr/david/ https://www.data.gouv.fr/fr/datasets/base-sirene-des-entreprises-et-de-leurs-etablissements-siren-siret/ Petits générateurs Python def extract_csv_filepaths(folder): for dirpath, dirnames, filenames in os.walk(folder): for filename in filenames: if filename.endswith('.csv'): yield os.path.join(dirpath, filename) def iter_over_csv_file(csv_filepath): with open(csv_filepath) as csv_file: for i, data in enumerate( csv.DictReader(csv_file, delimiter=';')): yield i, data https://github.com/etalab/sirene/blob/master/ulysse/utils.py#L20-L32 3. Données compréhensibles → documentation David Larlet — https://larlet.fr/david/ https://www.data.gouv.fr/fr/datasets/base-sirene-des-entreprises-et-de-leurs-etablissements-siren-siret/ Structures performantes class Town(namedtuple('Town', [ 'id', 'actual', ...])): """Inherit from a namedtuple with empty slots for performances.""" __slots__ = () class Towns(OrderedDict): https://github.com/etalab/geohisto/blob/master/geohisto/models.py#L98 4. Données interopérables → formats ouverts David Larlet — https://larlet.fr/david/ https://github.com/etalab/secateur#api Décorateurs et DX def in_case_of(*actions): def inner(func): for action in actions: ACTIONS[action] = func @wraps(func) def inner_func(towns, record): func(towns, record) return inner_func return inner @in_case_of(CHANGE_NAME, CHANGE_NAME_FUSION) def change_name(towns, record): https://github.com/etalab/geohisto/blob/master/geohisto/utils.py#L23-L33 5. Données requêtables → API/CLI David Larlet — https://larlet.fr/david/ https://github.com/etalab/sirene#tools CSV def sniff_dialect(self, csvfile_in, extract_length=4096): extract = csvfile_in.read(extract_length) try: dialect = csv.Sniffer().sniff(extract) except csv.Error: dialect = csv.unix_dialect() csvfile_in.seek(0) return dialect def write_bom(self, csvfile_out, encoding): """Make Excel happy with UTF-8 using a BOM.""" if encoding.startswith('utf-8'): csvfile_out.write(codecs.BOM_UTF8.decode('utf-8')) https://github.com/davidbgk/etalab/blob/master/secateur/reducer.py#L43-L60 6. Données conviviales → prévisualisation David Larlet — https://larlet.fr/david/ https://github.com/etalab/geohisto/blob/master/exports/towns/towns_head.csv 7. Données résilientes → distribution David Larlet — https://larlet.fr/david/ https://github.com/etalab/geohisto/releases 8. Données pérennes → historique David Larlet — https://larlet.fr/david/ https://github.com/etalab/sirene#dealing-with-history-optional 9. Gouvernance ouverte → échanges David Larlet — https://larlet.fr/david/ https://github.com/etalab/geohisto/issues 10. Bien commun → vie propre David Larlet — https://larlet.fr/david/ Libération d’une donnée == lâcher-prise progressif David Larlet — https://larlet.fr/david/ Administration → mise en relation David Larlet — https://larlet.fr/david/ Et au Canada ? David Larlet — https://larlet.fr/david/ Résumé écrit https://larlet.fr/david/blog/ 2017/donnees-communs/ David Larlet — https://larlet.fr/david/