pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ron <ronljohnsonjr@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: Copying data from a CSV file into a table dynamically
Date: Tue, 14 Aug 2018 08:46:43 -0500
Message-ID: <f006356c-f45f-41c3-a0ff-28b918602be3@gmail.com> (raw)
In-Reply-To: <1534253907682-0.post@n3.nabble.com>
References: <1534252253597-0.post@n3.nabble.com>
	<318228ff-6861-8a69-981f-48cb528a0dd9@aklaver.com>
	<1534253907682-0.post@n3.nabble.com>

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.




view thread (8+ messages)  latest in thread

Message-ID: <f006356c-f45f-41c3-a0ff-28b918602be3@gmail.com>
Permalink:  ../f006356c-f45f-41c3-a0ff-28b918602be3@gmail.com/
Also on:    postgresql.org/message-id/f006356c-f45f-41c3-a0ff-28b918602be3@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: ronljohnsonjr@gmail.com
  Subject: Re: Copying data from a CSV file into a table dynamically
  In-Reply-To: <f006356c-f45f-41c3-a0ff-28b918602be3@gmail.com>
  References: <1534252253597-0.post@n3.nabble.com> <318228ff-6861-8a69-981f-48cb528a0dd9@aklaver.com> <1534253907682-0.post@n3.nabble.com> <f006356c-f45f-41c3-a0ff-28b918602be3@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox