Skip to content

Commit

Permalink
added export to CSV with CSVT file
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugh Saalmans committed Nov 17, 2022
1 parent 1f8d039 commit fc8eb7c
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions testing/xx_export_to_csv.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash

# need a Python 3.10+ environment with GDAL 3.6.0 and PyArrow
conda deactivate
conda activate geo

# get the directory this script is running from
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

OUTPUT_FOLDER="/Users/$(whoami)/tmp/gdal-testing"
mkdir -p "${OUTPUT_FOLDER}"
cd "${OUTPUT_FOLDER}"


# convert Postgres table to CSV with CSVT field types file
input_schema="gnaf_202208"
input_table="address_principals"

echo "Exporting ${input_schema}.${input_table}"

ogr2ogr \
-f CSV \
"${OUTPUT_FOLDER}/${input_table}.csv" \
PG:"host='localhost' dbname='geo' user='postgres' password='password' port='5432'" \
"${input_schema}.${input_table}(geom)" \
-lco CREATE_CSVT=YES

0 comments on commit fc8eb7c

Please sign in to comment.