From: Tim Cross <theophilusx@gmail.com>
To: Anto Aravinth <anto.aravinth.cse@gmail.com>
Cc: Adrien Nayrat <adrien.nayrat@anayrat.info>
Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: Using COPY to import large xml file
Date: Tue, 26 Jun 2018 08:10:29 +1000
Message-ID: <8736xaseju.fsf@gmail.com> (raw)
In-Reply-To: <CANtp6R+4mm9HmrcVbSCCE_k3gXeCgnbuoL7UjibZoZJwoehrcg@mail.gmail.com>
References: <CANtp6R+Xu_LmGEA9-5OvX=h+7UqEppJfTgB8P9EcbkLOOO0Xtw@mail.gmail.com>
<95bb81dd-a80a-a493-2c3b-c03848acefc8@anayrat.info>
<CANtp6R+VFj2=qD6+DR7Hpzg1c_cQRHG-W5kENsre3yQesJHHxw@mail.gmail.com>
<874lhrsugr.fsf@gmail.com>
<CANtp6RLW-UuRr2xQkVt74S_+u3Ad_bVM7npGNzF8BE1YyZwEWA@mail.gmail.com>
<CAC=50j-RRKf-pTnbAYwcKJi90yYZ9T=L+JyNhtJKuZjDY1m=ow@mail.gmail.com>
<CANtp6R+4mm9HmrcVbSCCE_k3gXeCgnbuoL7UjibZoZJwoehrcg@mail.gmail.com>
Anto Aravinth <anto.aravinth.cse@gmail.com> writes:
> Thanks a lot. But I do got lot of challenges! Looks like SO data contains
> lot of tabs within itself.. So tabs delimiter didn't work for me. I thought
> I can give a special demiliter but looks like Postrgesql copy allow only
> one character as delimiter :(
>
> Sad, I guess only way is to insert or do a through serialization of my data
> into something that COPY can understand.
>
The COPY command has a number of options, including setting what is used
as the delimiter - it doesn't have to be tab. You need to also look at
the logs/output to see exactly why the copy fails.
I'd recommend first pre-processing your input data to make sure it is
'clean' and all the fields actually match with whatever DDL you have
used to define your db tables etc. I'd then select a small subset and
try different parameters to the copy command until you get the right
combination of data format and copy definition.
It may take some effort to get the right combination, but the result is
probably worth it given your data set size i.e. difference between hours
and days.
--
Tim Cross
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: theophilusx@gmail.com, anto.aravinth.cse@gmail.com, adrien.nayrat@anayrat.info
Subject: Re: Using COPY to import large xml file
In-Reply-To: <8736xaseju.fsf@gmail.com>
References: <CANtp6R+Xu_LmGEA9-5OvX=h+7UqEppJfTgB8P9EcbkLOOO0Xtw@mail.gmail.com> <95bb81dd-a80a-a493-2c3b-c03848acefc8@anayrat.info> <CANtp6R+VFj2=qD6+DR7Hpzg1c_cQRHG-W5kENsre3yQesJHHxw@mail.gmail.com> <874lhrsugr.fsf@gmail.com> <CANtp6RLW-UuRr2xQkVt74S_+u3Ad_bVM7npGNzF8BE1YyZwEWA@mail.gmail.com> <CAC=50j-RRKf-pTnbAYwcKJi90yYZ9T=L+JyNhtJKuZjDY1m=ow@mail.gmail.com> <CANtp6R+4mm9HmrcVbSCCE_k3gXeCgnbuoL7UjibZoZJwoehrcg@mail.gmail.com> <8736xaseju.fsf@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