Re: How to insert a string with '/' using COPY command from a text file

From: Richard Huxton <dev(at)archonet(dot)com>
To: "shreedhar" <shreedhar(at)lucidindia(dot)net>, "Postgre General" <pgsql-general(at)postgresql(dot)org>
Subject: Re: How to insert a string with '/' using COPY command from a text file
Date: 2003-04-10 11:29:15
Message-ID: 200304101229.15116.dev@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thursday 10 Apr 2003 11:32 am, shreedhar wrote:
> Hello All
>
>
> tblTemp (
> catalogid INTEGER NOT NULL DEFAULT 0,
> DirPath Varchar(250) NOT NULL DEFAULT '',
> TypeName VARCHAR(100) NOT NULL DEFAULT '',
> size FLOAT NOT NULL DEFAULT 0,
> filedate datetime NOT NULL
> ) ;
>
> Input text file
> 10|cdrom\games\themes\newyears1.zip|WinZip File (Folder)|729990|11/24/2001
> 01:41:32 AM
>
> If I directly use Copy command
>
> 1) data is storing in table as following
>
> catalogid dirpath typename
> size filedate 10
> cdromgamesthemesnewyears1.zip WinZip File 729990
> 2001-11-24 01:41:32

You probably want to escape the backslashes, so you have something like:

10|cdrom\\games\\themes\\newyears1.zip...

In your examples you seem to be using / (forward slash) rather than \
(back-slash). Some codes that might get you:

\t tab
\r carriage-return
\n newline

So - anywhere you have backslash in your input make sure you double it.

--
Richard Huxton

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Himmet Karaman 2003-04-10 12:44:40 PLEASE HELP ME about choosing entries while entering data to fields
Previous Message shreedhar 2003-04-10 10:32:19 How to insert a string with '/' using COPY command from a text file