pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Phillip Smith <phillip.smith@weatherbeeta.com.au>
To: Paul Lambert <paul.lambert@autoledgers.com.au>
Cc: pgsql-sql@postgresql.org
Subject: Re: Issue with copying data from a text file.
Date: Tue, 20 Mar 2007 13:37:16 +1100
Message-ID: <1174358236.10466.14.camel@it-laptop> (raw)
In-Reply-To: <45FF4622.2010404@autoledgers.com.au>
References: <45FF4622.2010404@autoledgers.com.au>

Can you not export the source file with escape characters? ie, 

^17\" Alloy Wheels^

~p

On Tue, 2007-03-20 at 11:25 +0900, Paul Lambert wrote:

> I have a procedure in place that copies data from a caret delimited text 
> file into a table storing some information.
> 
> One of the fields in the table contains an item description which may 
> contain item dimensions such as - 17" alloy wheels
> 
> The problem I am getting when I do my load is I believe due to the 
> presence of the double quotation marks giving the copy the impression 
> that it is to include the information following as a single text string 
> until it gets to the next set of double quotes. As a result, I get the 
> following:
> 
> AutoDRS=#       COPY deal_lines_temp_load FROM 
> 'c:/temp/autodrs_deal_lines.txt'
> WITH DELIMITER AS '^' CSV HEADER;
> ERROR:  value too long for type character varying(30)
> CONTEXT:  COPY deal_lines_temp_load, line 87, column order_desc: "17 5 
> spoke alloy wheels.^1291.18^117.38^983.69^1291.18^^C^^
> 
> The column as you can see is defined as a 30 character field, the load 
> contains in this column ^17" 5 spoke alloy wheels.^
> 
> I note an option in the COPY command to specify the quote character, 
> defaulting to double quote. The problem being a single quote will also 
> be used in the data, as will other characters. Is there any way to get a 
> copy to have no quote character? I.e. read the file and put whatever is 
> between the caret characters straight into the appropriate field exactly 
> as is.
> 
> TIA,
> Paul.
> 

Phillip Smith
IT Coordinator
Weatherbeeta P/L
8 Moncrief Rd
Nunawading, Vic, 3131
AUSTRALIA

P. +613 9845 0600
F. +613 9845 0655
E. phillip.smith@weatherbeeta.com.au

Attachments:

  smime.p7s (application/x-pkcs7-signature, 2.1K) download

view thread (9+ messages)  latest in thread

Message-ID: <1174358236.10466.14.camel@it-laptop>
Permalink:  ../1174358236.10466.14.camel@it-laptop/
Also on:    postgresql.org/message-id/1174358236.10466.14.camel@it-laptop

 · 

reply

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: phillip.smith@weatherbeeta.com.au, paul.lambert@autoledgers.com.au
  Subject: Re: Issue with copying data from a text file.
  In-Reply-To: <1174358236.10466.14.camel@it-laptop>

* 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