pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedBack Slash \ issue
31+ messages / 12 participants
[nested] [flat]
* Back Slash \ issue
@ 2019-05-02 12:20 Guntry Vinod <GV00619735@TechMahindra.com>
0 siblings, 2 replies; 31+ messages in thread
From: Guntry Vinod @ 2019-05-02 12:20 UTC (permalink / raw)
To: pgsql-general; +Cc: Venkatamurali Krishna Gottuparthi <VG00114307@TechMahindra.com>; Biswa Ranjan Dash <BD00617837@TechMahindra.com>
Hi Team,
We have dump from DB2 and trying to upload it Postgre.
The records which has \(back ward) are failing to import.
Can anyone in the team help us to resolve the issue.
Can you also let us know if we are posting the question to the right team.
Regards,
Vinod
============================================================================================================================
Disclaimer: This message and the information contained herein is proprietary and confidential and subject to the Tech Mahindra policy statement, you may review the policy at http://www.techmahindra.com/Disclaimer.html <http://www.techmahindra.com/Disclaimer.html; externally http://tim.techmahindra.com/tim/disclaimer.html <http://tim.techmahindra.com/tim/disclaimer.html; internally within TechMahindra.
============================================================================================================================
^ permalink raw reply [nested|flat] 31+ messages in thread
* Re: Back Slash \ issue
@ 2019-05-02 14:23 Adrian Klaver <adrian.klaver@aklaver.com>
parent: Guntry Vinod <GV00619735@TechMahindra.com>
1 sibling, 0 replies; 31+ messages in thread
From: Adrian Klaver @ 2019-05-02 14:23 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
On 5/2/19 5:20 AM, Guntry Vinod wrote:
> Hi Team,
>
> We have dump from DB2 and trying to upload it Postgre.
What program did you use to take the dump?
How are you importing the data into Postgres(note the 's')?
What is the exact error message?
>
> The records which has \(back ward) are failing to import.
>
> Can anyone in the team help us to resolve the issue.
>
> Can you also let us know if we are posting the question to the right team.
>
> Regards,
>
> Vinod
>
> ============================================================================================================================
>
> Disclaimer: This message and the information contained herein is
> proprietary and confidential and subject to the Tech Mahindra policy
> statement, you may review the policy at
> http://www.techmahindra.com/Disclaimer.html externally
> http://tim.techmahindra.com/tim/disclaimer.html internally within
> TechMahindra.
>
> ============================================================================================================================
>
--
Adrian Klaver
adrian.klaver@aklaver.com
^ permalink raw reply [nested|flat] 31+ messages in thread
* Re: Back Slash \ issue
@ 2019-05-02 14:30 ravikrishna@mail.com
parent: Guntry Vinod <GV00619735@TechMahindra.com>
1 sibling, 1 reply; 31+ messages in thread
From: ravikrishna@mail.com @ 2019-05-02 14:30 UTC (permalink / raw)
To: Guntry Vinod <GV00619735@TechMahindra.com>; +Cc: pgsql-general; Venkatamurali Krishna Gottuparthi <VG00114307@TechMahindra.com>; Biswa Ranjan Dash <BD00617837@TechMahindra.com>
<html><head></head><body><div style="font-family: Verdana;font-size: 12.0px;"><div>> We have dump from DB2 and trying to upload it Postgre.</div>
<div> </div>
<div>DB2 export command has an option to export it as CSV which quotes data so that any embedded</div>
<div>lines or special characters inside the data is treated fine. Does the csv format has quotes enclosing it ?</div></div></body></html>
^ permalink raw reply [nested|flat] 31+ messages in thread
* Re: Back Slash \ issue
@ 2019-05-02 14:34 Adrian Klaver <adrian.klaver@aklaver.com>
parent: ravikrishna@mail.com
0 siblings, 2 replies; 31+ messages in thread
From: Adrian Klaver @ 2019-05-02 14:34 UTC (permalink / raw)
To: ravikrishna@mail.com; Guntry Vinod <GV00619735@TechMahindra.com>; +Cc: pgsql-general; Venkatamurali Krishna Gottuparthi <VG00114307@TechMahindra.com>; Biswa Ranjan Dash <BD00617837@TechMahindra.com>
On 5/2/19 7:30 AM, ravikrishna@mail.com wrote:
> > We have dump from DB2 and trying to upload it Postgre.
> DB2 export command has an option to export it as CSV which quotes data
> so that any embedded
> lines or special characters inside the data is treated fine. Does the
> csv format has quotes enclosing it ?
Please show the command you use to import into Postgres.
Also the error message you get.
--
Adrian Klaver
adrian.klaver@aklaver.com
^ permalink raw reply [nested|flat] 31+ messages in thread
* Re: Back Slash \ issue
@ 2019-05-02 14:37 Adrian Klaver <adrian.klaver@aklaver.com>
parent: Adrian Klaver <adrian.klaver@aklaver.com>
1 sibling, 0 replies; 31+ messages in thread
From: Adrian Klaver @ 2019-05-02 14:37 UTC (permalink / raw)
To: ravikrishna@mail.com; Guntry Vinod <GV00619735@TechMahindra.com>; +Cc: pgsql-general; Venkatamurali Krishna Gottuparthi <VG00114307@TechMahindra.com>; Biswa Ranjan Dash <BD00617837@TechMahindra.com>
On 5/2/19 7:34 AM, Adrian Klaver wrote:
> On 5/2/19 7:30 AM, ravikrishna@mail.com wrote:
>> > We have dump from DB2 and trying to upload it Postgre.
>> DB2 export command has an option to export it as CSV which quotes data
>> so that any embedded
>> lines or special characters inside the data is treated fine. Does the
>> csv format has quotes enclosing it ?
>
> Please show the command you use to import into Postgres.
> Also the error message you get.
Oops was not paying attention to sender, ignore above.
--
Adrian Klaver
adrian.klaver@aklaver.com
^ permalink raw reply [nested|flat] 31+ messages in thread
* RE: Back Slash \ issue
@ 2019-05-02 15:19 Guntry Vinod <GV00619735@TechMahindra.com>
parent: Adrian Klaver <adrian.klaver@aklaver.com>
1 sibling, 2 replies; 31+ messages in thread
From: Guntry Vinod @ 2019-05-02 15:19 UTC (permalink / raw)
To: Adrian Klaver <adrian.klaver@aklaver.com>; ravikrishna@mail.com <ravikrishna@mail.com>; +Cc: pgsql-general; Venkatamurali Krishna Gottuparthi <VG00114307@TechMahindra.com>; Biswa Ranjan Dash <BD00617837@TechMahindra.com>
Hi Adrian\Kiran,
Below is the issue.
We are migrating from Db2 to Postgre.
The Db2 dump consists of back Slash \ with in the data [dump] , but postgre is not escaping the Slash.
For example if name consist of Vinod\G after the inserting the dump the value in postgre is VinodG where as I need it as Vinod\G.
Since the dump is huge data I can't replace \ within the data to escape Slash.
We are using import utility provided by Postgre.
Can you please give me any solution in this regard?.
@kiran-let me also try solution you provided in the below mail.
Regards,
Vinod
_______________________________________
From: Adrian Klaver [adrian.klaver@aklaver.com]
Sent: 02 May 2019 20:04
To: ravikrishna@mail.com; Guntry Vinod
Cc: pgsql-general@postgresql.org; Venkatamurali Krishna Gottuparthi; Biswa Ranjan Dash
Subject: Re: Back Slash \ issue
On 5/2/19 7:30 AM, ravikrishna@mail.com wrote:
> > We have dump from DB2 and trying to upload it Postgre.
> DB2 export command has an option to export it as CSV which quotes data
> so that any embedded
> lines or special characters inside the data is treated fine. Does the
> csv format has quotes enclosing it ?
Please show the command you use to import into Postgres.
Also the error message you get.
--
Adrian Klaver
adrian.klaver@aklaver.com
============================================================================================================================
Disclaimer: This message and the information contained herein is proprietary and confidential and subject to the Tech Mahindra policy statement, you may review the policy at http://www.techmahindra.com/Disclaimer.html <http://www.techmahindra.com/Disclaimer.html; externally http://tim.techmahindra.com/tim/disclaimer.html <http://tim.techmahindra.com/tim/disclaimer.html; internally within TechMahindra.
============================================================================================================================
^ permalink raw reply [nested|flat] 31+ messages in thread
* Re: Back Slash \ issue
@ 2019-05-02 15:27 Adrian Klaver <adrian.klaver@aklaver.com>
parent: Guntry Vinod <GV00619735@TechMahindra.com>
1 sibling, 1 reply; 31+ messages in thread
From: Adrian Klaver @ 2019-05-02 15:27 UTC (permalink / raw)
To: Guntry Vinod <GV00619735@TechMahindra.com>; ravikrishna@mail.com <ravikrishna@mail.com>; +Cc: pgsql-general; Venkatamurali Krishna Gottuparthi <VG00114307@TechMahindra.com>; Biswa Ranjan Dash <BD00617837@TechMahindra.com>
On 5/2/19 8:19 AM, Guntry Vinod wrote:
> Hi Adrian\Kiran,
>
> Below is the issue.
>
> We are migrating from Db2 to Postgre.
>
> The Db2 dump consists of back Slash \ with in the data [dump] , but postgre is not escaping the Slash.
>
> For example if name consist of Vinod\G after the inserting the dump the value in postgre is VinodG where as I need it as Vinod\G.
>
> Since the dump is huge data I can't replace \ within the data to escape Slash.
>
> We are using import utility provided by Postgre.
Are you talking about COPY or some other utility?
>
> Can you please give me any solution in this regard?.
In order for a solution to be found we will need more explicit
information on what you are doing.
>
> @kiran-let me also try solution you provided in the below mail.
>
> Regards,
> Vinod
> _______________________________________
> From: Adrian Klaver [adrian.klaver@aklaver.com]
> Sent: 02 May 2019 20:04
> To: ravikrishna@mail.com; Guntry Vinod
> Cc: pgsql-general@postgresql.org; Venkatamurali Krishna Gottuparthi; Biswa Ranjan Dash
> Subject: Re: Back Slash \ issue
>
> On 5/2/19 7:30 AM, ravikrishna@mail.com wrote:
>> > We have dump from DB2 and trying to upload it Postgre.
>> DB2 export command has an option to export it as CSV which quotes data
>> so that any embedded
>> lines or special characters inside the data is treated fine. Does the
>> csv format has quotes enclosing it ?
>
> Please show the command you use to import into Postgres.
> Also the error message you get.
>
>
> --
> Adrian Klaver
> adrian.klaver@aklaver.com
> ============================================================================================================================
>
> Disclaimer: This message and the information contained herein is proprietary and confidential and subject to the Tech Mahindra policy statement, you may review the policy at http://www.techmahindra.com/Disclaimer.html <http://www.techmahindra.com/Disclaimer.html; externally http://tim.techmahindra.com/tim/disclaimer.html <http://tim.techmahindra.com/tim/disclaimer.html; internally within TechMahindra.
>
> ============================================================================================================================
>
>
--
Adrian Klaver
adrian.klaver@aklaver.com
^ permalink raw reply [nested|flat] 31+ messages in thread
* Re: Back Slash \ issue
@ 2019-05-02 16:54 Rob Sargent <robjsargent@gmail.com>
parent: Guntry Vinod <GV00619735@TechMahindra.com>
1 sibling, 1 reply; 31+ messages in thread
From: Rob Sargent @ 2019-05-02 16:54 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
On 5/2/19 9:19 AM, Guntry Vinod wrote:
> Hi Adrian\Kiran,
>
> Below is the issue.
>
> We are migrating from Db2 to Postgre.
>
> The Db2 dump consists of back Slash \ with in the data [dump] , but postgre is not escaping the Slash.
>
> For example if name consist of Vinod\G after the inserting the dump the value in postgre is VinodG where as I need it as Vinod\G.
Have you tried somlething like
sed 's/\\/\\\\/g' db2dump > db2dump.fixed
>
> Since the dump is huge data I can't replace \ within the data to escape Slash.
>
> We are using import utility provided by Postgre.
>
> Can you please give me any solution in this regard?.
>
> @kiran-let me also try solution you provided in the below mail.
>
> Regards,
> Vinod
> _______________________________________
> From: Adrian Klaver [adrian.klaver@aklaver.com]
> Sent: 02 May 2019 20:04
> To: ravikrishna@mail.com; Guntry Vinod
> Cc: pgsql-general@postgresql.org; Venkatamurali Krishna Gottuparthi; Biswa Ranjan Dash
> Subject: Re: Back Slash \ issue
>
> On 5/2/19 7:30 AM, ravikrishna@mail.com wrote:
>> > We have dump from DB2 and trying to upload it Postgre.
>> DB2 export command has an option to export it as CSV which quotes data
>> so that any embedded
>> lines or special characters inside the data is treated fine. Does the
>> csv format has quotes enclosing it ?
> Please show the command you use to import into Postgres.
> Also the error message you get.
>
>
> --
> Adrian Klaver
> adrian.klaver@aklaver.com
> ============================================================================================================================
>
> Disclaimer: This message and the information contained herein is proprietary and confidential and subject to the Tech Mahindra policy statement, you may review the policy at http://www.techmahindra.com/Disclaimer.html <http://www.techmahindra.com/Disclaimer.html; externally http://tim.techmahindra.com/tim/disclaimer.html <http://tim.techmahindra.com/tim/disclaimer.html; internally within TechMahindra.
>
> ============================================================================================================================
>
>
>
^ permalink raw reply [nested|flat] 31+ messages in thread
* Re: Back Slash \ issue
@ 2019-05-02 16:57 Melvin Davidson <melvin6925@gmail.com>
parent: Rob Sargent <robjsargent@gmail.com>
0 siblings, 0 replies; 31+ messages in thread
From: Melvin Davidson @ 2019-05-02 16:57 UTC (permalink / raw)
To: Rob Sargent <robjsargent@gmail.com>; +Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
Have you tried adding
ESCAPE '*\*' to the PostgreSQL COPY command?
https://www.postgresql.org/docs/10/sql-copy.html
On Thu, May 2, 2019 at 12:54 PM Rob Sargent <robjsargent@gmail.com> wrote:
>
> On 5/2/19 9:19 AM, Guntry Vinod wrote:
> > Hi Adrian\Kiran,
> >
> > Below is the issue.
> >
> > We are migrating from Db2 to Postgre.
> >
> > The Db2 dump consists of back Slash \ with in the data [dump] , but
> postgre is not escaping the Slash.
> >
> > For example if name consist of Vinod\G after the inserting the dump the
> value in postgre is VinodG where as I need it as Vinod\G.
>
> Have you tried somlething like
>
> sed 's/\\/\\\\/g' db2dump > db2dump.fixed
>
> >
> > Since the dump is huge data I can't replace \ within the data to escape
> Slash.
> >
> > We are using import utility provided by Postgre.
> >
> > Can you please give me any solution in this regard?.
> >
> > @kiran-let me also try solution you provided in the below mail.
> >
> > Regards,
> > Vinod
> > _______________________________________
> > From: Adrian Klaver [adrian.klaver@aklaver.com]
> > Sent: 02 May 2019 20:04
> > To: ravikrishna@mail.com; Guntry Vinod
> > Cc: pgsql-general@postgresql.org; Venkatamurali Krishna Gottuparthi;
> Biswa Ranjan Dash
> > Subject: Re: Back Slash \ issue
> >
> > On 5/2/19 7:30 AM, ravikrishna@mail.com wrote:
> >> > We have dump from DB2 and trying to upload it Postgre.
> >> DB2 export command has an option to export it as CSV which quotes data
> >> so that any embedded
> >> lines or special characters inside the data is treated fine. Does the
> >> csv format has quotes enclosing it ?
> > Please show the command you use to import into Postgres.
> > Also the error message you get.
> >
> >
> > --
> > Adrian Klaver
> > adrian.klaver@aklaver.com
> >
> ============================================================================================================================
> >
> > Disclaimer: This message and the information contained herein is
> proprietary and confidential and subject to the Tech Mahindra policy
> statement, you may review the policy at
> http://www.techmahindra.com/Disclaimer.html <
> http://www.techmahindra.com/Disclaimer.html; externally
> http://tim.techmahindra.com/tim/disclaimer.html <
> http://tim.techmahindra.com/tim/disclaimer.html; internally within
> TechMahindra.
> >
> >
> ============================================================================================================================
> >
> >
> >
>
>
>
--
*Melvin Davidson*
*Maj. Database & Exploration Specialist*
*Universe Exploration Command – UXC*
Employment by invitation only!
^ permalink raw reply [nested|flat] 31+ messages in thread
* RE: Back Slash \ issue
@ 2019-05-03 05:48 Guntry Vinod <GV00619735@TechMahindra.com>
parent: Adrian Klaver <adrian.klaver@aklaver.com>
0 siblings, 2 replies; 31+ messages in thread
From: Guntry Vinod @ 2019-05-03 05:48 UTC (permalink / raw)
To: Adrian Klaver <adrian.klaver@aklaver.com>; ravikrishna@mail.com <ravikrishna@mail.com>; pgsql-general; +Cc: Venkatamurali Krishna Gottuparthi <VG00114307@TechMahindra.com>; Biswa Ranjan Dash <BD00617837@TechMahindra.com>
Hi Team,
We are using the below command
COPY <<TableName>> from 'C:\Data_Dump\ABC.txt' DELIMITER '|';
Regards,
Vinod
-----Original Message-----
From: Adrian Klaver <adrian.klaver@aklaver.com>
Sent: Thursday, May 2, 2019 8:58 PM
To: Guntry Vinod <GV00619735@TechMahindra.com>; ravikrishna@mail.com
Cc: pgsql-general@postgresql.org; Venkatamurali Krishna Gottuparthi <VG00114307@TechMahindra.com>; Biswa Ranjan Dash <BD00617837@TechMahindra.com>
Subject: Re: Back Slash \ issue
On 5/2/19 8:19 AM, Guntry Vinod wrote:
> Hi Adrian\Kiran,
>
> Below is the issue.
>
> We are migrating from Db2 to Postgre.
>
> The Db2 dump consists of back Slash \ with in the data [dump] , but postgre is not escaping the Slash.
>
> For example if name consist of Vinod\G after the inserting the dump the value in postgre is VinodG where as I need it as Vinod\G.
>
> Since the dump is huge data I can't replace \ within the data to escape Slash.
>
> We are using import utility provided by Postgre.
Are you talking about COPY or some other utility?
>
> Can you please give me any solution in this regard?.
In order for a solution to be found we will need more explicit information on what you are doing.
>
> @kiran-let me also try solution you provided in the below mail.
>
> Regards,
> Vinod
> _______________________________________
> From: Adrian Klaver [adrian.klaver@aklaver.com]
> Sent: 02 May 2019 20:04
> To: ravikrishna@mail.com; Guntry Vinod
> Cc: pgsql-general@postgresql.org; Venkatamurali Krishna Gottuparthi;
> Biswa Ranjan Dash
> Subject: Re: Back Slash \ issue
>
> On 5/2/19 7:30 AM, ravikrishna@mail.com wrote:
>> > We have dump from DB2 and trying to upload it Postgre.
>> DB2 export command has an option to export it as CSV which quotes
>> data so that any embedded lines or special characters inside the data
>> is treated fine. Does the csv format has quotes enclosing it ?
>
> Please show the command you use to import into Postgres.
> Also the error message you get.
>
>
> --
> Adrian Klaver
> adrian.klaver@aklaver.com
> ======================================================================
> ======================================================
>
> Disclaimer: This message and the information contained herein is proprietary and confidential and subject to the Tech Mahindra policy statement, you may review the policy at http://www.techmahindra.com/Disclaimer.html <http://www.techmahindra.com/Disclaimer.html; externally http://tim.techmahindra.com/tim/disclaimer.html <http://tim.techmahindra.com/tim/disclaimer.html; internally within TechMahindra.
>
> ======================================================================
> ======================================================
>
>
--
Adrian Klaver
adrian.klaver@aklaver.com
^ permalink raw reply [nested|flat] 31+ messages in thread
* Re: Back Slash \ issue
@ 2019-05-03 08:07 Andrew Gierth <andrew@tao11.riddles.org.uk>
parent: Guntry Vinod <GV00619735@TechMahindra.com>
1 sibling, 1 reply; 31+ messages in thread
From: Andrew Gierth @ 2019-05-03 08:07 UTC (permalink / raw)
To: Guntry Vinod <GV00619735@TechMahindra.com>; +Cc: Adrian Klaver <adrian.klaver@aklaver.com>; ravikrishna\@mail.com <ravikrishna@mail.com>; pgsql-general; Venkatamurali Krishna Gottuparthi <VG00114307@TechMahindra.com>; Biswa Ranjan Dash <BD00617837@TechMahindra.com>
>>>>> "Guntry" == Guntry Vinod <GV00619735@TechMahindra.com> writes:
Guntry> Hi Team,
Guntry> We are using the below command
Guntry> COPY <<TableName>> from 'C:\Data_Dump\ABC.txt' DELIMITER '|';
COPY in postgresql expects one of two data formats; since you did not
specify CSV, in this case it's expecting the default postgresql format
which requires the use of \ for escapes like \r, \n, \t, \\, \012 and
for the default NULL specification of \N.
If you use this format it is therefore your responsibility to ensure
that any literal \ characters in the data are escaped as \\, and that
any literal appearance of the delimiter character or a newline is also
escaped.
See https://www.postgresql.org/docs/current/sql-copy.html under "Text
format".
--
Andrew (irc:RhodiumToad)
^ permalink raw reply [nested|flat] 31+ messages in thread
* RE: Back Slash \ issue
@ 2019-05-03 08:45 Guntry Vinod <GV00619735@TechMahindra.com>
parent: Andrew Gierth <andrew@tao11.riddles.org.uk>
0 siblings, 1 reply; 31+ messages in thread
From: Guntry Vinod @ 2019-05-03 08:45 UTC (permalink / raw)
To: Andrew Gierth <andrew@tao11.riddles.org.uk>; pgsql-general; +Cc: Adrian Klaver <adrian.klaver@aklaver.com>; ravikrishna@mail.com <ravikrishna@mail.com>; Venkatamurali Krishna Gottuparthi <VG00114307@TechMahindra.com>; Biswa Ranjan Dash <BD00617837@TechMahindra.com>
Hi Andrew,
So you mean to say we need to replace \\ in data. If so the data what we receive is huge chunk(we cannot open in notepad++ also) .
If we can pass the CSV instead of .txt or any other format. Do we have any solution. if Yes Can you please give me some example.
Many Thanks,
Vinod
-----Original Message-----
From: Andrew Gierth <andrew@tao11.riddles.org.uk>
Sent: Friday, May 3, 2019 1:37 PM
To: Guntry Vinod <GV00619735@TechMahindra.com>
Cc: Adrian Klaver <adrian.klaver@aklaver.com>; ravikrishna@mail.com; pgsql-general@postgresql.org; Venkatamurali Krishna Gottuparthi <VG00114307@TechMahindra.com>; Biswa Ranjan Dash <BD00617837@TechMahindra.com>
Subject: Re: Back Slash \ issue
>>>>> "Guntry" == Guntry Vinod <GV00619735@TechMahindra.com> writes:
Guntry> Hi Team,
Guntry> We are using the below command
Guntry> COPY <<TableName>> from 'C:\Data_Dump\ABC.txt' DELIMITER '|';
COPY in postgresql expects one of two data formats; since you did not specify CSV, in this case it's expecting the default postgresql format which requires the use of \ for escapes like \r, \n, \t, \\, \012 and for the default NULL specification of \N.
If you use this format it is therefore your responsibility to ensure that any literal \ characters in the data are escaped as \\, and that any literal appearance of the delimiter character or a newline is also escaped.
See https://www.postgresql.org/docs/current/sql-copy.html under "Text format".
--
Andrew (irc:RhodiumToad)
============================================================================================================================
Disclaimer: This message and the information contained herein is proprietary and confidential and subject to the Tech Mahindra policy statement, you may review the policy at http://www.techmahindra.com/Disclaimer.html <http://www.techmahindra.com/Disclaimer.html; externally http://tim.techmahindra.com/tim/disclaimer.html <http://tim.techmahindra.com/tim/disclaimer.html; internally within TechMahindra.
============================================================================================================================
^ permalink raw reply [nested|flat] 31+ messages in thread
* Re: Back Slash \ issue
@ 2019-05-03 09:01 Matthias Apitz <guru@unixarea.de>
parent: Guntry Vinod <GV00619735@TechMahindra.com>
0 siblings, 1 reply; 31+ messages in thread
From: Matthias Apitz @ 2019-05-03 09:01 UTC (permalink / raw)
To: Guntry Vinod <GV00619735@TechMahindra.com>; +Cc: Andrew Gierth <andrew@tao11.riddles.org.uk>; pgsql-general; Adrian Klaver <adrian.klaver@aklaver.com>; ravikrishna@mail.com <ravikrishna@mail.com>; Venkatamurali Krishna Gottuparthi <VG00114307@TechMahindra.com>; Biswa Ranjan Dash <BD00617837@TechMahindra.com>
El día Friday, May 03, 2019 a las 08:45:02AM +0000, Guntry Vinod escribió:
> Hi Andrew,
>
> So you mean to say we need to replace \\ in data. If so the data what we receive is huge chunk(we cannot open in notepad++ also) .
>
> ...
Hi Guntry,
What about piping the data on a Linux or any other UNIX (or even Cygwin
on Windows) through a sed-Kommand to do the necessary changes, like
echo 'bla\foo' | sed 's/\\/\\\\/'
bla\\foo
matthias
--
Matthias Apitz, ✉ guru@unixarea.de, http://www.unixarea.de/ +49-176-38902045
Public GnuPG key: http://www.unixarea.de/key.pub
70 years of NATO - 70 years of wars (Jugoslavia, Afghanistan, Syria, ...) and 70 years
of war preparation against Russia. -- PEACE instead of NATO !
^ permalink raw reply [nested|flat] 31+ messages in thread
* RE: Back Slash \ issue
@ 2019-05-03 09:04 Guntry Vinod <GV00619735@TechMahindra.com>
parent: Matthias Apitz <guru@unixarea.de>
0 siblings, 2 replies; 31+ messages in thread
From: Guntry Vinod @ 2019-05-03 09:04 UTC (permalink / raw)
To: Matthias Apitz <guru@unixarea.de>; +Cc: Andrew Gierth <andrew@tao11.riddles.org.uk>; pgsql-general; Adrian Klaver <adrian.klaver@aklaver.com>; ravikrishna@mail.com <ravikrishna@mail.com>; Venkatamurali Krishna Gottuparthi <VG00114307@TechMahindra.com>; Biswa Ranjan Dash <BD00617837@TechMahindra.com>
The postgre is running on Windows platform.
-----Original Message-----
From: Matthias Apitz <guru@unixarea.de>
Sent: Friday, May 3, 2019 2:32 PM
To: Guntry Vinod <GV00619735@TechMahindra.com>
Cc: Andrew Gierth <andrew@tao11.riddles.org.uk>; pgsql-general@postgresql.org; Adrian Klaver <adrian.klaver@aklaver.com>; ravikrishna@mail.com; Venkatamurali Krishna Gottuparthi <VG00114307@TechMahindra.com>; Biswa Ranjan Dash <BD00617837@TechMahindra.com>
Subject: Re: Back Slash \ issue
El día Friday, May 03, 2019 a las 08:45:02AM +0000, Guntry Vinod escribió:
> Hi Andrew,
>
> So you mean to say we need to replace \\ in data. If so the data what we receive is huge chunk(we cannot open in notepad++ also) .
>
> ...
Hi Guntry,
What about piping the data on a Linux or any other UNIX (or even Cygwin on Windows) through a sed-Kommand to do the necessary changes, like
echo 'bla\foo' | sed 's/\\/\\\\/'
bla\\foo
matthias
--
Matthias Apitz, ✉ guru@unixarea.de, http://www.unixarea.de/ +49-176-38902045 Public GnuPG key: http://www.unixarea.de/key.pub
70 years of NATO - 70 years of wars (Jugoslavia, Afghanistan, Syria, ...) and 70 years of war preparation against Russia. -- PEACE instead of NATO !
============================================================================================================================
Disclaimer: This message and the information contained herein is proprietary and confidential and subject to the Tech Mahindra policy statement, you may review the policy at http://www.techmahindra.com/Disclaimer.html <http://www.techmahindra.com/Disclaimer.html; externally http://tim.techmahindra.com/tim/disclaimer.html <http://tim.techmahindra.com/tim/disclaimer.html; internally within TechMahindra.
============================================================================================================================
^ permalink raw reply [nested|flat] 31+ messages in thread
* RE: Back Slash \ issue
@ 2019-05-03 09:16 Biswa Ranjan Dash <BD00617837@TechMahindra.com>
parent: Guntry Vinod <GV00619735@TechMahindra.com>
1 sibling, 0 replies; 31+ messages in thread
From: Biswa Ranjan Dash @ 2019-05-03 09:16 UTC (permalink / raw)
To: Guntry Vinod <GV00619735@TechMahindra.com>; Matthias Apitz <guru@unixarea.de>; +Cc: Andrew Gierth <andrew@tao11.riddles.org.uk>; pgsql-general; Adrian Klaver <adrian.klaver@aklaver.com>; ravikrishna@mail.com <ravikrishna@mail.com>; Venkatamurali Krishna Gottuparthi <VG00114307@TechMahindra.com>
Team,
We had also tried importing the data by converting the data to a CSV file using
\copy TABLE_NAME FROM 'G:\DB_Backup\FILE.csv' (format csv, null '\N');
Regards,
Biswa
-----Original Message-----
From: Guntry Vinod <GV00619735@TechMahindra.com>
Sent: Friday, May 3, 2019 2:35 PM
To: Matthias Apitz <guru@unixarea.de>
Cc: Andrew Gierth <andrew@tao11.riddles.org.uk>; pgsql-general@postgresql.org; Adrian Klaver <adrian.klaver@aklaver.com>; ravikrishna@mail.com; Venkatamurali Krishna Gottuparthi <VG00114307@TechMahindra.com>; Biswa Ranjan Dash <BD00617837@TechMahindra.com>
Subject: RE: Back Slash \ issue
The postgre is running on Windows platform.
-----Original Message-----
From: Matthias Apitz <guru@unixarea.de>
Sent: Friday, May 3, 2019 2:32 PM
To: Guntry Vinod <GV00619735@TechMahindra.com>
Cc: Andrew Gierth <andrew@tao11.riddles.org.uk>; pgsql-general@postgresql.org; Adrian Klaver <adrian.klaver@aklaver.com>; ravikrishna@mail.com; Venkatamurali Krishna Gottuparthi <VG00114307@TechMahindra.com>; Biswa Ranjan Dash <BD00617837@TechMahindra.com>
Subject: Re: Back Slash \ issue
El día Friday, May 03, 2019 a las 08:45:02AM +0000, Guntry Vinod escribió:
> Hi Andrew,
>
> So you mean to say we need to replace \\ in data. If so the data what we receive is huge chunk(we cannot open in notepad++ also) .
>
> ...
Hi Guntry,
What about piping the data on a Linux or any other UNIX (or even Cygwin on Windows) through a sed-Kommand to do the necessary changes, like
echo 'bla\foo' | sed 's/\\/\\\\/'
bla\\foo
matthias
--
Matthias Apitz, ✉ guru@unixarea.de, http://www.unixarea.de/ +49-176-38902045 Public GnuPG key: http://www.unixarea.de/key.pub
70 years of NATO - 70 years of wars (Jugoslavia, Afghanistan, Syria, ...) and 70 years of war preparation against Russia. -- PEACE instead of NATO !
============================================================================================================================
Disclaimer: This message and the information contained herein is proprietary and confidential and subject to the Tech Mahindra policy statement, you may review the policy at http://www.techmahindra.com/Disclaimer.html <http://www.techmahindra.com/Disclaimer.html; externally http://tim.techmahindra.com/tim/disclaimer.html <http://tim.techmahindra.com/tim/disclaimer.html; internally within TechMahindra.
============================================================================================================================
^ permalink raw reply [nested|flat] 31+ messages in thread
* Re: Back Slash \ issue
@ 2019-05-03 10:03 Matthias Apitz <guru@unixarea.de>
parent: Guntry Vinod <GV00619735@TechMahindra.com>
1 sibling, 0 replies; 31+ messages in thread
From: Matthias Apitz @ 2019-05-03 10:03 UTC (permalink / raw)
To: Guntry Vinod <GV00619735@TechMahindra.com>; +Cc: Andrew Gierth <andrew@tao11.riddles.org.uk>; pgsql-general; Adrian Klaver <adrian.klaver@aklaver.com>; ravikrishna@mail.com <ravikrishna@mail.com>; Venkatamurali Krishna Gottuparthi <VG00114307@TechMahindra.com>; Biswa Ranjan Dash <BD00617837@TechMahindra.com>
El día Friday, May 03, 2019 a las 09:04:34AM +0000, Guntry Vinod escribió:
> The postgre is running on Windows platform.
Maybe you haven't read completely through the post you are top posting
on. It was clear to me (from the used file name syntax) that you are on
Windows; that's why I said:
> What about piping the data on a Linux or any other UNIX (or even Cygwin on Windows)
> through a sed-Kommand to do the necessary changes, like ...
i.e you could use Windows for this. Or transfer the data for processing
to a Linux system, and back for loading.
matthias
--
Matthias Apitz, ✉ guru@unixarea.de, http://www.unixarea.de/ +49-176-38902045
Public GnuPG key: http://www.unixarea.de/key.pub
70 years of NATO - 70 years of wars (Jugoslavia, Afghanistan, Syria, ...) and 70 years
of war preparation against Russia. -- PEACE instead of NATO !
^ permalink raw reply [nested|flat] 31+ messages in thread
* Re: Back Slash \ issue
@ 2019-05-03 13:55 Adrian Klaver <adrian.klaver@aklaver.com>
parent: Guntry Vinod <GV00619735@TechMahindra.com>
1 sibling, 2 replies; 31+ messages in thread
From: Adrian Klaver @ 2019-05-03 13:55 UTC (permalink / raw)
To: Guntry Vinod <GV00619735@TechMahindra.com>; ravikrishna@mail.com <ravikrishna@mail.com>; pgsql-general; +Cc: Venkatamurali Krishna Gottuparthi <VG00114307@TechMahindra.com>; Biswa Ranjan Dash <BD00617837@TechMahindra.com>
On 5/2/19 10:48 PM, Guntry Vinod wrote:
Please do not top post. Inline/bottom posting is the preferred style on
this list.
> Hi Team,
>
> We are using the below command
>
> COPY <<TableName>> from 'C:\Data_Dump\ABC.txt' DELIMITER '|';
The above shows what you are doing on the input into Postgres.
We still do not know how you are dumping the data from DB2.
In what format are you dumping the DB2 data and with what specifications
e.g. quoting?
>
> Regards,
> Vinod
--
Adrian Klaver
adrian.klaver@aklaver.com
^ permalink raw reply [nested|flat] 31+ messages in thread
* Re: Back Slash \ issue
@ 2019-05-03 14:04 Bruce Momjian <bruce@momjian.us>
parent: Adrian Klaver <adrian.klaver@aklaver.com>
1 sibling, 1 reply; 31+ messages in thread
From: Bruce Momjian @ 2019-05-03 14:04 UTC (permalink / raw)
To: Adrian Klaver <adrian.klaver@aklaver.com>; +Cc: Guntry Vinod <GV00619735@TechMahindra.com>; ravikrishna@mail.com <ravikrishna@mail.com>; pgsql-general; Venkatamurali Krishna Gottuparthi <VG00114307@TechMahindra.com>; Biswa Ranjan Dash <BD00617837@TechMahindra.com>
On Fri, May 3, 2019 at 06:55:55AM -0700, Adrian Klaver wrote:
> On 5/2/19 10:48 PM, Guntry Vinod wrote:
>
> Please do not top post. Inline/bottom posting is the preferred style on this
> list.
> > Hi Team,
> >
> > We are using the below command
> >
> > COPY <<TableName>> from 'C:\Data_Dump\ABC.txt' DELIMITER '|';
>
> The above shows what you are doing on the input into Postgres.
> We still do not know how you are dumping the data from DB2.
>
> In what format are you dumping the DB2 data and with what specifications
> e.g. quoting?
On thing the original poster might be missing is that the copy DELIMITER
is used between fields, while backslash is used as an escape before a
single character. While it might be tempting to try to redefine the
escape character with the copy ESCAPE keyword, that keyword only works
in CSV mode.
The Postgres COPY format is very reliable and able to dump/reload _any_
data sequence. Many commercial data dump implementations are simpler
but are not able to be as reliable.
The bottom line is that you are going to need to double the backslashes
unless you move to CSV mode.
--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ As you are, so once was I. As I am, so you will be. +
+ Ancient Roman grave inscription +
^ permalink raw reply [nested|flat] 31+ messages in thread
* Re: Back Slash \ issue
@ 2019-05-03 14:10 Bruce Momjian <bruce@momjian.us>
parent: Bruce Momjian <bruce@momjian.us>
0 siblings, 0 replies; 31+ messages in thread
From: Bruce Momjian @ 2019-05-03 14:10 UTC (permalink / raw)
To: Adrian Klaver <adrian.klaver@aklaver.com>; +Cc: Guntry Vinod <GV00619735@TechMahindra.com>; ravikrishna@mail.com <ravikrishna@mail.com>; pgsql-general; Venkatamurali Krishna Gottuparthi <VG00114307@TechMahindra.com>; Biswa Ranjan Dash <BD00617837@TechMahindra.com>
On Fri, May 3, 2019 at 10:04:44AM -0400, Bruce Momjian wrote:
> On thing the original poster might be missing is that the copy DELIMITER
> is used between fields, while backslash is used as an escape before a
> single character. While it might be tempting to try to redefine the
> escape character with the copy ESCAPE keyword, that keyword only works
> in CSV mode.
>
> The Postgres COPY format is very reliable and able to dump/reload _any_
> data sequence. Many commercial data dump implementations are simpler
> but are not able to be as reliable.
For example, if you are using | as a delimiter, how do you represent a
literal | in the data? You have to use an escape character before it,
and that is what backslash does, and if you have a backslash in your
data, you have to use a backslash before it too. CSV has a similar
problem with double-quotes in double-quoted strings, and this is handled
by default by using two double-quotes.
--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ As you are, so once was I. As I am, so you will be. +
+ Ancient Roman grave inscription +
^ permalink raw reply [nested|flat] 31+ messages in thread
* Re: Back Slash \ issue
@ 2019-05-03 14:35 Ravi Krishna <ravikrishna@mail.com>
parent: Adrian Klaver <adrian.klaver@aklaver.com>
1 sibling, 2 replies; 31+ messages in thread
From: Ravi Krishna @ 2019-05-03 14:35 UTC (permalink / raw)
To: Adrian Klaver <adrian.klaver@aklaver.com>; +Cc: Guntry Vinod <GV00619735@TechMahindra.com>; pgsql-general; Venkatamurali Krishna Gottuparthi <VG00114307@TechMahindra.com>; Biswa Ranjan Dash <BD00617837@TechMahindra.com>
>
> In what format are you dumping the DB2 data and with what specifications e.g. quoting?
>
DB2's export command quotes the data with "". So while loading, shouldn't that take care of delimiter-in-the-data issue ?
^ permalink raw reply [nested|flat] 31+ messages in thread
* Re: Back Slash \ issue
@ 2019-05-03 14:39 Adrian Klaver <adrian.klaver@aklaver.com>
parent: Ravi Krishna <ravikrishna@mail.com>
1 sibling, 0 replies; 31+ messages in thread
From: Adrian Klaver @ 2019-05-03 14:39 UTC (permalink / raw)
To: Ravi Krishna <ravikrishna@mail.com>; +Cc: Guntry Vinod <GV00619735@TechMahindra.com>; pgsql-general; Venkatamurali Krishna Gottuparthi <VG00114307@TechMahindra.com>; Biswa Ranjan Dash <BD00617837@TechMahindra.com>
On 5/3/19 7:35 AM, Ravi Krishna wrote:
>>
>> In what format are you dumping the DB2 data and with what specifications e.g. quoting?
>>
>
> DB2's export command quotes the data with "". So while loading, shouldn't that take care of delimiter-in-the-data issue ?
>
In the original post the only info was:
"We have dump from DB2 and trying to upload it Postgre."
That is a little vague, I would prefer more concrete information before
proposing a solution.
--
Adrian Klaver
adrian.klaver@aklaver.com
^ permalink raw reply [nested|flat] 31+ messages in thread
* Re: Back Slash \ issue
@ 2019-05-03 14:43 Michael Nolan <htfoot@gmail.com>
parent: Ravi Krishna <ravikrishna@mail.com>
1 sibling, 1 reply; 31+ messages in thread
From: Michael Nolan @ 2019-05-03 14:43 UTC (permalink / raw)
To: Ravi Krishna <ravikrishna@mail.com>; +Cc: Adrian Klaver <adrian.klaver@aklaver.com>; Guntry Vinod <GV00619735@techmahindra.com>; pgsql-general; Venkatamurali Krishna Gottuparthi <VG00114307@techmahindra.com>; Biswa Ranjan Dash <BD00617837@techmahindra.com>
On Fri, May 3, 2019 at 9:35 AM Ravi Krishna <ravikrishna@mail.com> wrote:
> >
> > In what format are you dumping the DB2 data and with what specifications
> e.g. quoting?
> >
>
> DB2's export command quotes the data with "". So while loading, shouldn't
> that take care of delimiter-in-the-data issue ?
>
I don't think we've seen enough representative data to know exactly what
the backslash is doing. It doesn't appear to be an escape, based on the
sole example I've seen it appears to be a data separator between first name
and last name.
It seems increasingly likely to me that you might not be in a position
where the COPY command in PostgreSQL can handle loading the database, at
least not without some help. You might have to write a program to clean up
the data and format it for PostgreSQL.
I've spent a lot of time over the years migrating data from one platform to
another, you have to know EXACTLY what data you currently have and what
format you need it turned into before you can figure out how to do the
transformation.
--
Mike Nolan
^ permalink raw reply [nested|flat] 31+ messages in thread
* Re: Back Slash \ issue
@ 2019-05-03 15:13 Ravi Krishna <ravikrishna@mail.com>
parent: Michael Nolan <htfoot@gmail.com>
0 siblings, 1 reply; 31+ messages in thread
From: Ravi Krishna @ 2019-05-03 15:13 UTC (permalink / raw)
To: Michael Nolan <htfoot@gmail.com>; +Cc: Adrian Klaver <adrian.klaver@aklaver.com>; Guntry Vinod <GV00619735@techmahindra.com>; pgsql-general; Venkatamurali Krishna Gottuparthi <VG00114307@techmahindra.com>; Biswa Ranjan Dash <BD00617837@techmahindra.com>
>
> I don't think we've seen enough representative data to know exactly what the backslash is doing. It doesn't appear to be an escape, based on the sole example I've seen it appears to be a data separator between first name and last name.
>
> It seems increasingly likely to me that you might not be in a position where the COPY command in PostgreSQL can handle loading the database, at least not without some help. You might have to write a program to clean up the data and format it for PostgreSQL.
>
> I've spent a lot of time over the years migrating data from one platform to another, you have to know EXACTLY what data you currently have and what format you need it turned into before you can figure out how to do the transformation.
> --
> Mike Nolan
Fully agreed. I have informed Guntry via email that he has to provide more information before we can help further.
^ permalink raw reply [nested|flat] 31+ messages in thread
* RE: Back Slash \ issue
@ 2019-05-03 16:05 Guntry Vinod <GV00619735@TechMahindra.com>
parent: Ravi Krishna <ravikrishna@mail.com>
0 siblings, 5 replies; 31+ messages in thread
From: Guntry Vinod @ 2019-05-03 16:05 UTC (permalink / raw)
To: Ravi Krishna <ravikrishna@mail.com>; Michael Nolan <htfoot@gmail.com>; +Cc: Adrian Klaver <adrian.klaver@aklaver.com>; pgsql-general; Venkatamurali Krishna Gottuparthi <VG00114307@TechMahindra.com>; Biswa Ranjan Dash <BD00617837@TechMahindra.com>
Hi Team,
Here we go. I will give the problem in more detail
Step 1:We get the dump from DB2 and this dump is flat file which can be csv,txt
Step2:There is table in PostGre where we are suppose to upload the dump
Step3:We are using copy command to upload dump to the table using (COPY <<TableName>> from 'C:\Data_Dump\ABC.txt' DELIMITER '|'; )
Step 4:In the above step we are using delimiter because the data is separated (:) in the flat which we have received from the flat file
Problem Statement:We are able to upload the data from the flat file which we got from the DB2 but few data the data consist of " \".For example if the CustomerName is Vinod\G in the flat file ,we expect the same data in PostGre table for CustomerName as Vinod\G but we see VinodG(slash is missed).
Possible Solution: We can replace "\" with "\\" but if the file is in too large we cannot open it(we can replace if the file is medium or small)
Expectation: We need a command or utility which can upload the data as it is (for example if Vinod\G then we should see in PostGre as Vinod\G but not VinodG)
Hope Iam detail this time :-)
Regards,
Vinod
-----Original Message-----
From: Ravi Krishna <ravikrishna@mail.com>
Sent: Friday, May 3, 2019 8:43 PM
To: Michael Nolan <htfoot@gmail.com>
Cc: Adrian Klaver <adrian.klaver@aklaver.com>; Guntry Vinod <GV00619735@TechMahindra.com>; pgsql-general@postgresql.org; Venkatamurali Krishna Gottuparthi <VG00114307@TechMahindra.com>; Biswa Ranjan Dash <BD00617837@TechMahindra.com>
Subject: Re: Back Slash \ issue
>
> I don't think we've seen enough representative data to know exactly what the backslash is doing. It doesn't appear to be an escape, based on the sole example I've seen it appears to be a data separator between first name and last name.
>
> It seems increasingly likely to me that you might not be in a position where the COPY command in PostgreSQL can handle loading the database, at least not without some help. You might have to write a program to clean up the data and format it for PostgreSQL.
>
> I've spent a lot of time over the years migrating data from one platform to another, you have to know EXACTLY what data you currently have and what format you need it turned into before you can figure out how to do the transformation.
> --
> Mike Nolan
Fully agreed. I have informed Guntry via email that he has to provide more information before we can help further.
============================================================================================================================
Disclaimer: This message and the information contained herein is proprietary and confidential and subject to the Tech Mahindra policy statement, you may review the policy at http://www.techmahindra.com/Disclaimer.html <http://www.techmahindra.com/Disclaimer.html; externally http://tim.techmahindra.com/tim/disclaimer.html <http://tim.techmahindra.com/tim/disclaimer.html; internally within TechMahindra.
============================================================================================================================
^ permalink raw reply [nested|flat] 31+ messages in thread
* Re: Back Slash \ issue
@ 2019-05-03 16:07 Ravi Krishna <ravikrishna@mail.com>
parent: Guntry Vinod <GV00619735@TechMahindra.com>
4 siblings, 0 replies; 31+ messages in thread
From: Ravi Krishna @ 2019-05-03 16:07 UTC (permalink / raw)
To: Guntry Vinod <GV00619735@TechMahindra.com>; +Cc: Michael Nolan <htfoot@gmail.com>; Adrian Klaver <adrian.klaver@aklaver.com>; pgsql-general; Venkatamurali Krishna Gottuparthi <VG00114307@TechMahindra.com>; Biswa Ranjan Dash <BD00617837@TechMahindra.com>
>
> Hope Iam detail this time :-)
>
Unfortunately still not enough. Can you post sample of the data here. And what command you used in DB2. Pls post the SQL used in DB2 to dump the data.
^ permalink raw reply [nested|flat] 31+ messages in thread
* Re: Back Slash \ issue
@ 2019-05-03 16:09 Adrian Klaver <adrian.klaver@aklaver.com>
parent: Guntry Vinod <GV00619735@TechMahindra.com>
4 siblings, 0 replies; 31+ messages in thread
From: Adrian Klaver @ 2019-05-03 16:09 UTC (permalink / raw)
To: Guntry Vinod <GV00619735@TechMahindra.com>; Ravi Krishna <ravikrishna@mail.com>; Michael Nolan <htfoot@gmail.com>; +Cc: pgsql-general; Venkatamurali Krishna Gottuparthi <VG00114307@TechMahindra.com>; Biswa Ranjan Dash <BD00617837@TechMahindra.com>
On 5/3/19 9:05 AM, Guntry Vinod wrote:
> Hi Team,
>
> Here we go. I will give the problem in more detail
>
> Step 1:We get the dump from DB2 and this dump is flat file which can be csv,txt
The above is what we need information on:
1) Is it output as CSV or text?
2) What are the parameters used to output the data in either case?. In
other words, is string quoting used, the field delimiter, etc.
> Step2:There is table in PostGre where we are suppose to upload the dump
> Step3:We are using copy command to upload dump to the table using (COPY <<TableName>> from 'C:\Data_Dump\ABC.txt' DELIMITER '|'; )
> Step 4:In the above step we are using delimiter because the data is separated (:) in the flat which we have received from the flat file
>
> Problem Statement:We are able to upload the data from the flat file which we got from the DB2 but few data the data consist of " \".For example if the CustomerName is Vinod\G in the flat file ,we expect the same data in PostGre table for CustomerName as Vinod\G but we see VinodG(slash is missed).
>
> Possible Solution: We can replace "\" with "\\" but if the file is in too large we cannot open it(we can replace if the file is medium or small)
>
> Expectation: We need a command or utility which can upload the data as it is (for example if Vinod\G then we should see in PostGre as Vinod\G but not VinodG)
>
> Hope Iam detail this time :-)
>
> Regards,
> Vinod
>
>
>
>
> -----Original Message-----
> From: Ravi Krishna <ravikrishna@mail.com>
> Sent: Friday, May 3, 2019 8:43 PM
> To: Michael Nolan <htfoot@gmail.com>
> Cc: Adrian Klaver <adrian.klaver@aklaver.com>; Guntry Vinod <GV00619735@TechMahindra.com>; pgsql-general@postgresql.org; Venkatamurali Krishna Gottuparthi <VG00114307@TechMahindra.com>; Biswa Ranjan Dash <BD00617837@TechMahindra.com>
> Subject: Re: Back Slash \ issue
>
>>
>> I don't think we've seen enough representative data to know exactly what the backslash is doing. It doesn't appear to be an escape, based on the sole example I've seen it appears to be a data separator between first name and last name.
>>
>> It seems increasingly likely to me that you might not be in a position where the COPY command in PostgreSQL can handle loading the database, at least not without some help. You might have to write a program to clean up the data and format it for PostgreSQL.
>>
>> I've spent a lot of time over the years migrating data from one platform to another, you have to know EXACTLY what data you currently have and what format you need it turned into before you can figure out how to do the transformation.
>> --
>> Mike Nolan
>
> Fully agreed. I have informed Guntry via email that he has to provide more information before we can help further.
> ============================================================================================================================
>
> Disclaimer: This message and the information contained herein is proprietary and confidential and subject to the Tech Mahindra policy statement, you may review the policy at http://www.techmahindra.com/Disclaimer.html <http://www.techmahindra.com/Disclaimer.html; externally http://tim.techmahindra.com/tim/disclaimer.html <http://tim.techmahindra.com/tim/disclaimer.html; internally within TechMahindra.
>
> ============================================================================================================================
>
--
Adrian Klaver
adrian.klaver@aklaver.com
^ permalink raw reply [nested|flat] 31+ messages in thread
* Re: Back Slash \ issue
@ 2019-05-03 16:17 Adrian Klaver <adrian.klaver@aklaver.com>
parent: Guntry Vinod <GV00619735@TechMahindra.com>
4 siblings, 1 reply; 31+ messages in thread
From: Adrian Klaver @ 2019-05-03 16:17 UTC (permalink / raw)
To: Guntry Vinod <GV00619735@TechMahindra.com>; Ravi Krishna <ravikrishna@mail.com>; Michael Nolan <htfoot@gmail.com>; +Cc: pgsql-general; Venkatamurali Krishna Gottuparthi <VG00114307@TechMahindra.com>; Biswa Ranjan Dash <BD00617837@TechMahindra.com>
On 5/3/19 9:05 AM, Guntry Vinod wrote:
> Hi Team,
>
> Here we go. I will give the problem in more detail
>
> Step 1:We get the dump from DB2 and this dump is flat file which can be csv,txt
> Step2:There is table in PostGre where we are suppose to upload the dump
> Step3:We are using copy command to upload dump to the table using (COPY <<TableName>> from 'C:\Data_Dump\ABC.txt' DELIMITER '|'; )
Should have been in my previous post. The answer to whether Step 1 is
text or CSV is important as that determines the way you use the COPY
command above. As has been pointed out upstream using COPY assuming
text(as you are doing above) on a CSV file will create issues.
> Step 4:In the above step we are using delimiter because the data is separated (:) in the flat which we have received from the flat file
>
> Problem Statement:We are able to upload the data from the flat file which we got from the DB2 but few data the data consist of " \".For example if the CustomerName is Vinod\G in the flat file ,we expect the same data in PostGre table for CustomerName as Vinod\G but we see VinodG(slash is missed).
>
> Possible Solution: We can replace "\" with "\\" but if the file is in too large we cannot open it(we can replace if the file is medium or small)
>
> Expectation: We need a command or utility which can upload the data as it is (for example if Vinod\G then we should see in PostGre as Vinod\G but not VinodG)
>
> Hope Iam detail this time :-)
>
> Regards,
> Vinod
>
>
>
>
--
Adrian Klaver
adrian.klaver@aklaver.com
^ permalink raw reply [nested|flat] 31+ messages in thread
* Re: Back Slash \ issue
@ 2019-05-03 16:20 Michael Nolan <htfoot@gmail.com>
parent: Guntry Vinod <GV00619735@TechMahindra.com>
4 siblings, 1 reply; 31+ messages in thread
From: Michael Nolan @ 2019-05-03 16:20 UTC (permalink / raw)
To: Guntry Vinod <GV00619735@techmahindra.com>; +Cc: Ravi Krishna <ravikrishna@mail.com>; Adrian Klaver <adrian.klaver@aklaver.com>; pgsql-general; Venkatamurali Krishna Gottuparthi <VG00114307@techmahindra.com>; Biswa Ranjan Dash <BD00617837@techmahindra.com>
I'm still not clear what the backslash is for, it is ONLY to separate first
and last name? Can you change it to some other character?
Others have suggested you're in a Windows environment, that might limit
your options. How big is the file, is it possible to copy it to another
server to manipulate it?
--
Mike Nolan
^ permalink raw reply [nested|flat] 31+ messages in thread
* Re: Back Slash \ issue
@ 2019-05-03 16:27 Igor Korot <ikorot01@gmail.com>
parent: Michael Nolan <htfoot@gmail.com>
0 siblings, 0 replies; 31+ messages in thread
From: Igor Korot @ 2019-05-03 16:27 UTC (permalink / raw)
To: Michael Nolan <htfoot@gmail.com>; +Cc: Guntry Vinod <GV00619735@techmahindra.com>; Ravi Krishna <ravikrishna@mail.com>; Adrian Klaver <adrian.klaver@aklaver.com>; pgsql-general; Venkatamurali Krishna Gottuparthi <VG00114307@techmahindra.com>; Biswa Ranjan Dash <BD00617837@techmahindra.com>
Hi,
On Fri, May 3, 2019 at 11:20 AM Michael Nolan <htfoot@gmail.com> wrote:
>
>
>
> I'm still not clear what the backslash is for, it is ONLY to separate first and last name? Can you change it to some other character?
>
> Others have suggested you're in a Windows environment, that might limit your options. How big is the file, is it possible to copy it to another server to manipulate it?
Why not use something like Perl to process the data and then feed the
processed file to PostgreSQL?
Thank you.
> --
> Mike Nolan
^ permalink raw reply [nested|flat] 31+ messages in thread
* RE: Back Slash \ issue
@ 2019-05-03 16:40 Guntry Vinod <GV00619735@TechMahindra.com>
parent: Adrian Klaver <adrian.klaver@aklaver.com>
0 siblings, 0 replies; 31+ messages in thread
From: Guntry Vinod @ 2019-05-03 16:40 UTC (permalink / raw)
To: Adrian Klaver <adrian.klaver@aklaver.com>; Ravi Krishna <ravikrishna@mail.com>; Michael Nolan <htfoot@gmail.com>; Nikhil Anand2 <NA00586350@TechMahindra.com>; Shivasharana Patil <shivashara@TechMahindra.com>; +Cc: pgsql-general; Venkatamurali Krishna Gottuparthi <VG00114307@TechMahindra.com>; Biswa Ranjan Dash <BD00617837@TechMahindra.com>
Looping Nikhil and Shiva who are from Mainframe, DB2.
Nikhil/Shiva I am trying explain the problem to the team but there few questions which needs your intervention.
Regards,
Vinod
-----Original Message-----
From: Adrian Klaver <adrian.klaver@aklaver.com>
Sent: Friday, May 3, 2019 9:47 PM
To: Guntry Vinod <GV00619735@TechMahindra.com>; Ravi Krishna <ravikrishna@mail.com>; Michael Nolan <htfoot@gmail.com>
Cc: pgsql-general@postgresql.org; Venkatamurali Krishna Gottuparthi <VG00114307@TechMahindra.com>; Biswa Ranjan Dash <BD00617837@TechMahindra.com>
Subject: Re: Back Slash \ issue
On 5/3/19 9:05 AM, Guntry Vinod wrote:
> Hi Team,
>
> Here we go. I will give the problem in more detail
>
> Step 1:We get the dump from DB2 and this dump is flat file which can
> be csv,txt Step2:There is table in PostGre where we are suppose to
> upload the dump Step3:We are using copy command to upload dump to the
> table using (COPY <<TableName>> from 'C:\Data_Dump\ABC.txt' DELIMITER
> '|'; )
Should have been in my previous post. The answer to whether Step 1 is text or CSV is important as that determines the way you use the COPY command above. As has been pointed out upstream using COPY assuming text(as you are doing above) on a CSV file will create issues.
> Step 4:In the above step we are using delimiter because the data is
> separated (:) in the flat which we have received from the flat file
>
> Problem Statement:We are able to upload the data from the flat file which we got from the DB2 but few data the data consist of " \".For example if the CustomerName is Vinod\G in the flat file ,we expect the same data in PostGre table for CustomerName as Vinod\G but we see VinodG(slash is missed).
>
> Possible Solution: We can replace "\" with "\\" but if the file is in
> too large we cannot open it(we can replace if the file is medium or
> small)
>
> Expectation: We need a command or utility which can upload the data as
> it is (for example if Vinod\G then we should see in PostGre as Vinod\G
> but not VinodG)
>
> Hope Iam detail this time :-)
>
> Regards,
> Vinod
>
>
>
>
--
Adrian Klaver
adrian.klaver@aklaver.com
============================================================================================================================
Disclaimer: This message and the information contained herein is proprietary and confidential and subject to the Tech Mahindra policy statement, you may review the policy at http://www.techmahindra.com/Disclaimer.html <http://www.techmahindra.com/Disclaimer.html; externally http://tim.techmahindra.com/tim/disclaimer.html <http://tim.techmahindra.com/tim/disclaimer.html; internally within TechMahindra.
============================================================================================================================
^ permalink raw reply [nested|flat] 31+ messages in thread
* Re: Back Slash \ issue
@ 2019-05-03 16:42 Rob Sargent <robjsargent@gmail.com>
parent: Guntry Vinod <GV00619735@TechMahindra.com>
4 siblings, 0 replies; 31+ messages in thread
From: Rob Sargent @ 2019-05-03 16:42 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
On 5/3/19 10:05 AM, Guntry Vinod wrote:
> Hi Team,
>
> Here we go. I will give the problem in more detail
>
> Step 1:We get the dump from DB2 and this dump is flat file which can be csv,txt
> Step2:There is table in PostGre where we are suppose to upload the dump
> Step3:We are using copy command to upload dump to the table using (COPY <<TableName>> from 'C:\Data_Dump\ABC.txt' DELIMITER '|'; )
> Step 4:In the above step we are using delimiter because the data is separated (:) in the flat which we have received from the flat file
>
> Problem Statement:We are able to upload the data from the flat file which we got from the DB2 but few data the data consist of " \".For example if the CustomerName is Vinod\G in the flat file ,we expect the same data in PostGre table for CustomerName as Vinod\G but we see VinodG(slash is missed).
>
> Possible Solution: We can replace "\" with "\\" but if the file is in too large we cannot open it(we can replace if the file is medium or small)
>
> Expectation: We need a command or utility which can upload the data as it is (for example if Vinod\G then we should see in PostGre as Vinod\G but not VinodG)
>
>
So everything works except the backslashes disappear, correct? As many
have said all you need to do is double the backslashes, and apparently
you done that on small files. How have you done that? Perhaps with an
editor? For the large files you must use a tool (perl awk, even a
trivial C program) to double the backslashes.
^ permalink raw reply [nested|flat] 31+ messages in thread
end of thread, other threads:[~2019-05-03 16:42 UTC | newest]
Thread overview: 31+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-05-02 12:20 Back Slash \ issue Guntry Vinod <GV00619735@TechMahindra.com>
2019-05-02 14:23 ` Adrian Klaver <adrian.klaver@aklaver.com>
2019-05-02 14:30 ` ravikrishna@mail.com
2019-05-02 14:34 ` Adrian Klaver <adrian.klaver@aklaver.com>
2019-05-02 14:37 ` Adrian Klaver <adrian.klaver@aklaver.com>
2019-05-02 15:19 ` Guntry Vinod <GV00619735@TechMahindra.com>
2019-05-02 15:27 ` Adrian Klaver <adrian.klaver@aklaver.com>
2019-05-03 05:48 ` Guntry Vinod <GV00619735@TechMahindra.com>
2019-05-03 08:07 ` Andrew Gierth <andrew@tao11.riddles.org.uk>
2019-05-03 08:45 ` Guntry Vinod <GV00619735@TechMahindra.com>
2019-05-03 09:01 ` Matthias Apitz <guru@unixarea.de>
2019-05-03 09:04 ` Guntry Vinod <GV00619735@TechMahindra.com>
2019-05-03 09:16 ` Biswa Ranjan Dash <BD00617837@TechMahindra.com>
2019-05-03 10:03 ` Matthias Apitz <guru@unixarea.de>
2019-05-03 13:55 ` Adrian Klaver <adrian.klaver@aklaver.com>
2019-05-03 14:04 ` Bruce Momjian <bruce@momjian.us>
2019-05-03 14:10 ` Bruce Momjian <bruce@momjian.us>
2019-05-03 14:35 ` Ravi Krishna <ravikrishna@mail.com>
2019-05-03 14:39 ` Adrian Klaver <adrian.klaver@aklaver.com>
2019-05-03 14:43 ` Michael Nolan <htfoot@gmail.com>
2019-05-03 15:13 ` Ravi Krishna <ravikrishna@mail.com>
2019-05-03 16:05 ` Guntry Vinod <GV00619735@TechMahindra.com>
2019-05-03 16:07 ` Ravi Krishna <ravikrishna@mail.com>
2019-05-03 16:09 ` Adrian Klaver <adrian.klaver@aklaver.com>
2019-05-03 16:17 ` Adrian Klaver <adrian.klaver@aklaver.com>
2019-05-03 16:40 ` Guntry Vinod <GV00619735@TechMahindra.com>
2019-05-03 16:20 ` Michael Nolan <htfoot@gmail.com>
2019-05-03 16:27 ` Igor Korot <ikorot01@gmail.com>
2019-05-03 16:42 ` Rob Sargent <robjsargent@gmail.com>
2019-05-02 16:54 ` Rob Sargent <robjsargent@gmail.com>
2019-05-02 16:57 ` Melvin Davidson <melvin6925@gmail.com>
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