From: Adrian Klaver <adrian.klaver@aklaver.com>
To: postggen2020 s <postggen2020@gmail.com>
To: pgsql-admin@postgresql.org
To: pgsql-general@postgresql.org
Subject: Re: Suggestion to reduce COPY command output to csv file
Date: Wed, 4 Mar 2020 10:46:45 -0800
Message-ID: <a68d8440-574f-4a0c-5583-8c9b9509eb86@aklaver.com> (raw)
In-Reply-To: <CAJ=omAhsJ89HqBtLBhE33RjvQ6ykbZjtM18igf=T-42m-nveBQ@mail.gmail.com>
References: <CAJ=omAhsJ89HqBtLBhE33RjvQ6ykbZjtM18igf=T-42m-nveBQ@mail.gmail.com>
On 3/4/20 10:38 AM, postggen2020 s wrote:
> Hi Team,
> Thanks a lot all of you, for providing support peoples like me.
> Could you please provide a suggestion on COPY command.
>
> Environment:
> DB Version:9.5.15
> postgis:
> Table contain GIS data.
> I have a table with GIS data, its around 300MB and 2Lacks+ records. I
> want to export all the records to the CSV file. I can able to export the
> table data into a CSV file, but the exported CSV file size around 162MB.
> While I am trying to opening the excel it is taking a long time and also
> while applying vlookup excel is getting hang.
> I am using below command :
> \copy cities TO '/var/lib/pgsql/cities.csv' (DELIMITER ',', FORMAT
> 'csv', HEADER)
> I am trying to achieve the following :
> 1. The exported CSV file should have within 10MB.
You can select less then the entire table with a query:
https://www.postgresql.org/docs/9.5/sql-copy.html
query
A SELECT or VALUES command whose results are to be copied. Note
that parentheses are required around the query.
> 2. The excel file should open quickly and able to perform vlookups
> without any problems(like hang).
That is something you will need to take up with MS.
> Could you please provide suggestions on below queries:
> 1. what I am trying to achieve, is the right assumption?.
> 2. Can we use this command to use for the above use case?.
> 3. Is there any tool/extension available for the above use case.?
The MS Office data tools for pulling directly from database into
spreadsheet via ODBC.
Do you use a programming language?
If so use its libraries to pull data out and into CSV or directly into a
spreadsheet.
> Your inputs are highly appreciated.
> Regards,
> Postgadm.
--
Adrian Klaver
adrian.klaver@aklaver.com
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-admin@postgresql.org
Cc: adrian.klaver@aklaver.com, postggen2020@gmail.com, pgsql-general@postgresql.org
Subject: Re: Suggestion to reduce COPY command output to csv file
In-Reply-To: <a68d8440-574f-4a0c-5583-8c9b9509eb86@aklaver.com>
References: <CAJ=omAhsJ89HqBtLBhE33RjvQ6ykbZjtM18igf=T-42m-nveBQ@mail.gmail.com> <a68d8440-574f-4a0c-5583-8c9b9509eb86@aklaver.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