Importing 120 csv files bulk multiple - Mailing list pgsql-general

From Andrew Taylor
Subject Importing 120 csv files bulk multiple
Date
Msg-id CAFAE3Jzz2-3rpUh9DLpgFdkjmoxvyCNMZ5mhy9eExdic35nCVA@mail.gmail.com
Whole thread Raw
Responses Re: Importing 120 csv files bulk multiple  (Ryan Kelly <rpkelly22@gmail.com>)
Re: Importing 120 csv files bulk multiple  (Adrian Klaver <adrian.klaver@gmail.com>)
List pgsql-general
Hi,

As per title I need to import a load of csv files. So I wrote a bash script to generate the statements I needed (attached). However, this is failing on my ubuntu laptop - it seems to occasionally miss  the semicolon to execute. What I did was copy the text to clipboard and paste it in to bash. Is there maybe a way to open this file and evaluate it within psql? Output shown below:

COPY 11340
postgres=# copy postcode_input from '/home/andyt/projects/django-stringer/Other/codepo_gb/Data/ub.csv' using delimiters ','
postgres-# copy postcode_input from '/home/andyt/projects/django-stringer/Other/codepo_gb/Data/wa.csv' using delimiters ',';
ERROR:  syntax error at or near "copy"
LINE 2: copy postcode_input from '/home/andyt/projects/django-string...
        ^
postgres=# 
postgres=# copy postcode_input from '/home/andyt/projects/django-stringer/Other/codepo_gb/Data/w.csv' using delimiters ',';
COPY 19787
postgres=# 
postgres=# copy postcode_input from '/home/andyt/projects/django-stringer/Other/codepo_gb/Data/wf.csv' using delimiters ','
postgres-# copy postcode_input from '/home/andyt/projects/django-stringer/Other/codepo_gb/Data/wn.csv' using delimiters ',';
ERROR:  syntax error at or near "copy"
LINE 2: copy postcode_input from '/home/andyt/projects/django-string...
        ^
postgres=# copy postcode_input from '/home/andyt/projects/django-stringer/Other/codepo_gb/Data/wr.csv' using delimiters ',';
COPY 8381
postgres=# copy postcode_input from '/home/andyt/projects/django-stringer/Other/codepo_gb/Data/ws.csv' using delimiters ',';
COPY 9884
postgres=# copy postcode_input from '/home/andyt/projects/django-stringer/Other/codepo_gb/Data/wv.csv' using delimiters ',';
COPY 9440


Thanks,


Andy

Attachment

pgsql-general by date:

Previous
From: "Carlo Stonebanks"
Date:
Subject: Re: Tcl & PG on Win 7 64 bit - is it working for anyone?
Next
From: Ryan Kelly
Date:
Subject: Re: Importing 120 csv files bulk multiple