diff --git a/Copy-data-to-postgresql.md b/Copy-data-to-postgresql.md index d238dea..dd27512 100644 --- a/Copy-data-to-postgresql.md +++ b/Copy-data-to-postgresql.md @@ -31,11 +31,10 @@ head -n 100 /data/raw/BCG\ Report\ 01\ Customer\ Base\ Data\ -\ 2023-01-16.csv | Then we want to create a new file striping the header ``` -tail -n +2 /data/raw/data.csv | iconv -c -f ASCII -t UTF-8 > data.csv +tail -n +2 /data/raw/data.csv | iconv -c -f ASCII -t UTF-8 | psql -U postgres -h localhost -c "\copy customer_base_data from stdin with (FORMAT 'csv', DELIMITER ',', QUOTE '\"')" ``` -And finally we can insert the file - +To change the semicolon separator with comma: ``` -psql -U postgres -h localhost -c "\copy customer_base_data from 'data.csv' with (FORMAT 'csv', DELIMITER ',', QUOTE '\"')" +sed --expression='s/;/,/g' ``` \ No newline at end of file