pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedExtracting data into .csv format
7+ messages / 7 participants
[nested] [flat]
* Extracting data into .csv format
@ 2016-02-17 16:49 Ferrell, Denise D CTR NSWCDD, H11 <denise.ferrell.ctr@navy.mil>
2016-02-17 16:54 ` Re: Extracting data into .csv format Vivekanand Joshi <vjoshi@zetainteractive.com>
2016-02-17 16:55 ` Re: Extracting data into .csv format Stephen Tahmosh <stahmosh@shieldsrx.com>
2016-02-17 16:55 ` Re: Extracting data into .csv format David G. Johnston <david.g.johnston@gmail.com>
2016-02-17 17:00 ` Re: Extracting data into .csv format Ziggy Skalski <zskalski@afilias.info>
2016-02-18 00:27 ` Re: Extracting data into .csv format Shreeyansh Dba <shreeyansh2014@gmail.com>
2016-02-18 10:49 ` Re: Extracting data into .csv format Pierre Chevalier Géologue <pierrechevaliergeol@free.fr>
0 siblings, 6 replies; 7+ messages in thread
From: Ferrell, Denise D CTR NSWCDD, H11 @ 2016-02-17 16:49 UTC (permalink / raw)
To: pgsql-admin
Using PostgreSQL 9.3 on Linux
I'm trying to extract data into a comma delimited format and not having much success...seems to act totally different from Oracle. Does anyone have any suggestions?
Thank you in advance.
Denise
Attachments:
smime.p7s (application/pkcs7-signature, 5.5K) download
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Extracting data into .csv format
2016-02-17 16:49 Extracting data into .csv format Ferrell, Denise D CTR NSWCDD, H11 <denise.ferrell.ctr@navy.mil>
@ 2016-02-17 16:54 ` Vivekanand Joshi <vjoshi@zetainteractive.com>
5 siblings, 0 replies; 7+ messages in thread
From: Vivekanand Joshi @ 2016-02-17 16:54 UTC (permalink / raw)
To: Ferrell, Denise D CTR NSWCDD, H11 <denise.ferrell.ctr@navy.mil>; pgsql-admin
Please read this:
http://www.postgresql.org/docs/9.4/static/sql-copy.html
-----Original Message-----
From: pgsql-admin-owner@postgresql.org [mailto:pgsql-admin-owner@postgresql.org] On Behalf Of Ferrell, Denise D CTR NSWCDD, H11
Sent: Wednesday, February 17, 2016 10:19 PM
To: pgsql-admin@postgresql.org
Subject: [ADMIN] Extracting data into .csv format
Using PostgreSQL 9.3 on Linux
I'm trying to extract data into a comma delimited format and not having much success...seems to act totally different from Oracle. Does anyone have any suggestions?
Thank you in advance.
Denise
--
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Extracting data into .csv format
2016-02-17 16:49 Extracting data into .csv format Ferrell, Denise D CTR NSWCDD, H11 <denise.ferrell.ctr@navy.mil>
@ 2016-02-17 16:55 ` Stephen Tahmosh <stahmosh@shieldsrx.com>
5 siblings, 0 replies; 7+ messages in thread
From: Stephen Tahmosh @ 2016-02-17 16:55 UTC (permalink / raw)
To: Ferrell, Denise D CTR NSWCDD, H11 <denise.ferrell.ctr@navy.mil>; pgsql-admin
The "Copy" statement (and \copy for local access
COPY (
select * from (.........
) TO ' || '''' || filname || '''' || ' with csv header'
STeve
-----Original Message-----
From: pgsql-admin-owner@postgresql.org [mailto:pgsql-admin-owner@postgresql.org] On Behalf Of Ferrell, Denise D CTR NSWCDD, H11
Sent: Wednesday, February 17, 2016 11:49 AM
To: pgsql-admin@postgresql.org
Subject: [ADMIN] Extracting data into .csv format
Using PostgreSQL 9.3 on Linux
I'm trying to extract data into a comma delimited format and not having much success...seems to act totally different from Oracle. Does anyone have any suggestions?
Thank you in advance.
Denise
THIS MESSAGE (AND ALL ATTACHMENTS) IS INTENDED FOR THE USE OF THE PERSON OR ENTITY TO WHOM IT IS ADDRESSED AND MAY CONTAIN INFORMATION THAT IS PRIVILEGED, CONFIDENTIAL AND EXEMPT FROM DISCLOSURE UNDER APPLICABLE LAW. If you are not the intended recipient, your use of this message for any purpose is strictly prohibited. If you have received this communication in error, please delete the message without making any copies and notify the sender so that we may correct our records. Thank you.
--
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Extracting data into .csv format
2016-02-17 16:49 Extracting data into .csv format Ferrell, Denise D CTR NSWCDD, H11 <denise.ferrell.ctr@navy.mil>
@ 2016-02-17 16:55 ` David G. Johnston <david.g.johnston@gmail.com>
5 siblings, 0 replies; 7+ messages in thread
From: David G. Johnston @ 2016-02-17 16:55 UTC (permalink / raw)
To: Ferrell, Denise D CTR NSWCDD, H11 <denise.ferrell.ctr@navy.mil>; +Cc: pgsql-admin
On Wed, Feb 17, 2016 at 9:49 AM, Ferrell, Denise D CTR NSWCDD, H11 <
denise.ferrell.ctr@navy.mil> wrote:
> Using PostgreSQL 9.3 on Linux
>
> I'm trying to extract data into a comma delimited format and not having
> much success...seems to act totally different from Oracle. Does anyone
> have any suggestions?
>
In the documentation lookup the psql "\copy" meta-command along with the
SQL COPY command.
David J.
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Extracting data into .csv format
2016-02-17 16:49 Extracting data into .csv format Ferrell, Denise D CTR NSWCDD, H11 <denise.ferrell.ctr@navy.mil>
@ 2016-02-17 17:00 ` Ziggy Skalski <zskalski@afilias.info>
5 siblings, 0 replies; 7+ messages in thread
From: Ziggy Skalski @ 2016-02-17 17:00 UTC (permalink / raw)
To: pgsql-admin
On 2016-02-17 11:49 AM, Ferrell, Denise D CTR NSWCDD, H11 wrote:
> Using PostgreSQL 9.3 on Linux
>
> I'm trying to extract data into a comma delimited format and not having much success...seems to act totally different from Oracle. Does anyone have any suggestions?
>
> Thank you in advance.
> Denise
Have you tried something like i.e.:
psql -c "COPY ( QUERY ) TO STDOUT WITH CSV HEADER " > CSV_FILE.csv
Should do the trick (assuming it's basic output you're after).
Regards,
Ziggy
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Extracting data into .csv format
2016-02-17 16:49 Extracting data into .csv format Ferrell, Denise D CTR NSWCDD, H11 <denise.ferrell.ctr@navy.mil>
@ 2016-02-18 00:27 ` Shreeyansh Dba <shreeyansh2014@gmail.com>
5 siblings, 0 replies; 7+ messages in thread
From: Shreeyansh Dba @ 2016-02-18 00:27 UTC (permalink / raw)
To: Ferrell, Denise D CTR NSWCDD, H11 <denise.ferrell.ctr@navy.mil>; +Cc: pgsql-admin
On Wed, Feb 17, 2016 at 10:19 PM, Ferrell, Denise D CTR NSWCDD, H11 <
denise.ferrell.ctr@navy.mil> wrote:
> Using PostgreSQL 9.3 on Linux
>
> I'm trying to extract data into a comma delimited format and not having
> much success...seems to act totally different from Oracle. Does anyone
> have any suggestions?
>
> Thank you in advance.
> Denise
>
Hi Denise,
Please read below official documentation of copy command:
http://www.postgresql.org/docs/9.4/static/sql-copy.html
Or check below tutorial
http://www.gistutor.com/postgresqlpostgis/10-intermediate-postgresqlpostgis-tutorials/39-how-to-impo...
Hope this will solve your problem.
--
Thanks & Regards,
Harshad Adalkonda
Database Administrator
www.shreeyansh.com
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Extracting data into .csv format
2016-02-17 16:49 Extracting data into .csv format Ferrell, Denise D CTR NSWCDD, H11 <denise.ferrell.ctr@navy.mil>
@ 2016-02-18 10:49 ` Pierre Chevalier Géologue <pierrechevaliergeol@free.fr>
5 siblings, 0 replies; 7+ messages in thread
From: Pierre Chevalier Géologue @ 2016-02-18 10:49 UTC (permalink / raw)
To: Ferrell, Denise D CTR NSWCDD, H11 <denise.ferrell.ctr@navy.mil>; pgsql-admin
Hi,
Le 17/02/2016 17:49, Ferrell, Denise D CTR NSWCDD, H11 a écrit :
> Using PostgreSQL 9.3 on Linux
>
> I'm trying to extract data into a comma delimited format and not having
>much success...seems to act totally different from Oracle. Does anyone
>have any suggestions?
Just in case it helps you, I wrote a pair of very simple scripts, but
they have eased my life a lot:
* sql2csv:
https://github.com/pierrechtux/geolllibre/blob/master/sql2csv
sql2csv takes an SQL query as an argument, and spits out the result in
CSV. Just redirecting its output (>) makes a .csv file.
It is extremely trivial: just this is relevant:
echo "COPY ($1) TO stdout WITH CSV HEADER FORCE QUOTE *" | psql -X -h
$GLL_BD_HOST $GLL_BD_NAME
* csv2sql:
https://github.com/pierrechtux/geolllibre/blob/master/csv2sql
csv2sql works the other way: you give him a .csv file, and it dumps it
into your database, in a 'tmp_imports' schema (makes it easy for
cleaning...).
These utility scripts are very rough: all fields are considered as
strings (varchar), to be as generic as possible.
I use these 2 utilities in production daily, for a number of purposes,
including heavy diff'ing. So far, no worries, they proved to be very
reliable,
There are a couple of environment variables that should be just adapted
for a generic use: $GLL_BD_HOST and $GLL_BD_NAME.
My little 0.02€...
À+
Pierre
--
____________________________________________________________________________
Pierre Chevalier
PChGEI: Pierre Chevalier Géologue Et Informaticien
Partenaire DALIBO
Mesté Duran
32100 Condom
Tél+fax : 09 75 27 45 62
06 37 80 33 64
Émail : pierrechevaliergeolCHEZfree.fr
icq# : 10432285
jabber: pierre.chevalier1967@jabber.fr
http://pierremariechevalier.free.fr/pierre_chevalier_geologue
____________________________________________________________________________
--
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin
^ permalink raw reply [nested|flat] 7+ messages in thread
end of thread, other threads:[~2016-02-18 10:49 UTC | newest]
Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2016-02-17 16:49 Extracting data into .csv format Ferrell, Denise D CTR NSWCDD, H11 <denise.ferrell.ctr@navy.mil>
2016-02-17 16:54 ` Vivekanand Joshi <vjoshi@zetainteractive.com>
2016-02-17 16:55 ` Stephen Tahmosh <stahmosh@shieldsrx.com>
2016-02-17 16:55 ` David G. Johnston <david.g.johnston@gmail.com>
2016-02-17 17:00 ` Ziggy Skalski <zskalski@afilias.info>
2016-02-18 00:27 ` Shreeyansh Dba <shreeyansh2014@gmail.com>
2016-02-18 10:49 ` Pierre Chevalier Géologue <pierrechevaliergeol@free.fr>
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