Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Observatoire
observatoire-scripts
Commits
c220cff3
Commit
c220cff3
authored
Sep 30, 2019
by
Pierre Dittgen
Browse files
1st step: generating organizations.csv, websites.csv
parent
0dc9007e
Changes
1
Hide whitespace changes
Inline
Side-by-side
process_and_generate
0 → 100755
View file @
c220cff3
#!/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
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment