42 lines
1.2 KiB
Python
42 lines
1.2 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: UTF-8 -*-
|
|
|
|
from pycen import update_to_sql, con_sicen
|
|
import geopandas as gpd
|
|
import os
|
|
|
|
DIR = '/home/colas/Documents/9_PROJETS/4_SICEN/GN_MIGRATION'
|
|
|
|
def export(path_name, data, format='csv'):
|
|
detect_date = data.columns[data.columns.str.startswith('date')]
|
|
data[detect_date] = data[detect_date].astype(str)
|
|
df = data.to_wkt().drop(columns='geom',errors='ignore')
|
|
if format=='xlsx':
|
|
df.to_excel(path_name+'.%s'%format)
|
|
elif format=='csv':
|
|
df.to_csv(path_name+'.%s'%format)
|
|
else:
|
|
raise('format non prévu')
|
|
|
|
|
|
v_synthese_invertebre = 'v_synthese_invertebre'
|
|
v_synthese_vertebre = 'v_synthese_vertebre'
|
|
v_synthese_flore = 'v_synthese_flore'
|
|
|
|
sql = 'SELECT * FROM saisie.%s'%v_synthese_invertebre
|
|
v_inv = gpd.read_postgis(sql,con_sicen)
|
|
sql = 'SELECT * FROM saisie.%s'%v_synthese_vertebre
|
|
v_ver = gpd.read_postgis(sql,con_sicen)
|
|
sql = 'SELECT * FROM saisie.%s'%v_synthese_flore
|
|
v_flo = gpd.read_postgis(sql,con_sicen)
|
|
|
|
export(os.path.join(DIR,v_synthese_invertebre),v_inv)
|
|
export(os.path.join(DIR,v_synthese_vertebre),v_ver)
|
|
export(os.path.join(DIR,v_synthese_flore),v_flo)
|
|
|
|
|
|
v_ver.etude.unique()
|
|
v_ver.protocole.unique()
|
|
v_ver.lot_donnee.unique()
|
|
|