Commit c220cff3 authored by Pierre Dittgen's avatar Pierre Dittgen
Browse files

1st step: generating organizations.csv, websites.csv

parent 0dc9007e
#!/bin/bash
#
# Process downloaded and prepared data
#
# Generate:
# - geojson files
# - markdown file
# - sqlite db
# - csv files
# Common initializations
source lib/common.sh
# organizations.csv
generate_organizations_csv() {
echo "Generating organizations.csv"
ORG_TEMP_DIR=$CACHE_DIR/orga
mkdir -p $ORG_TEMP_DIR
$CSV_CUT -c "siren,type,url-ptf,url-datagouv,id-datagouv" $ODF_ORGA_FILE > $ORG_TEMP_DIR/odf_org_1.csv
$CSV_GREP -c "statut" -m "ok" $CACHE_DIR/siren_info.csv | $CSV_CUT -C "statut,message" > $ORG_TEMP_DIR/siren_ok_info.csv
$CSV_JOIN -c 1 $ORG_TEMP_DIR/odf_org.csv $ORG_TEMP_DIR/siren_ok_info.csv > $ORG_TEMP_DIR/odf_org_2.csv
$CSV_JOIN -c "code_departement,depcode" $ORG_TEMP_DIR/odf_org_2.csv $CACHE_DIR/cog_departement.csv > $ORG_TEMP_DIR/odf_org_3.csv
$CSV_JOIN -c "code_region,regcode" $ORG_TEMP_DIR/odf_org_3.csv $CACHE_DIR/cog_region.csv > $ORG_TEMP_DIR/odf_org_4.csv
ORGANIZATIONS_HEADER="siren,nom,type,url-website,url-datagouv,id-datagouv,reg-code,reg-nom,dep-code,dep-nom,lat,long"
(echo $ORGANIZATIONS_HEADER && $CSV_CUT -c "siren,nom,type,url-ptf,url-datagouv,id-datagouv,code_region,regnom,code_departement,depnom,latitude,longitude" $ORG_TEMP_DIR/odf_org_4.csv | $SED "1d") > $BUILD_DIR/organizations.csv
rm -fR $ORG_TEMP_DIR
}
generate_websites_csv() {
echo "Generating websites.csv"
WS_TEMP_DIR=$CACHE_DIR/website
mkdir -p $WS_TEMP_DIR
$CSV_CUT -c "nom,url,techno,porteur,contact,twitter" $ODF_PTF_FILE > $BUILD_DIR/websites.csv
}
generate_organizations_csv
generate_websites_csv
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment