Re: Copying data from a CSV file into a table dynamically - Mailing list pgsql-general

From Ron
Subject Re: Copying data from a CSV file into a table dynamically
Date
Msg-id f006356c-f45f-41c3-a0ff-28b918602be3@gmail.com
Whole thread Raw
In response to Re: Copying data from a CSV file into a table dynamically  (pavan95 <pavan.postgresdba@gmail.com>)
Responses Re: Copying data from a CSV file into a table dynamically
Re: Copying data from a CSV file into a table dynamically
List pgsql-general
On 08/14/2018 08:38 AM, pavan95 wrote:
> Hi Adrian,
>
> I tried to use
> *"COPY postgres_log1 FROM '/tmp/abc/xyz/postgresql-`date --date="0 days ago"
> +%Y-%m-%d`_*.csv' WITH csv;"*
>
> But it resulted in an error. How to issue such that it is understandable by
> psql?
>
> And I am completely unaware of python & psycopg2. Anything which suits my
> requirement is enough!!ostgresql-archive.org/PostgreSQL-general-f1843780.html

Why not:
cat /tmp/abc/xyz/postgresql-`date --date="0 days ago"+%Y-%m-%d`_*.csv' | \
        psql YOURDB -c "COPY postgres_log1 FROM STDIN WITH csv;"

-- 
Angular momentum makes the world go 'round.


pgsql-general by date:

Previous
From: pavan95
Date:
Subject: Re: Copying data from a CSV file into a table dynamically
Next
From: Vik Fearing
Date:
Subject: Re: Vacuum process waiting on BufferPin