Re: Issue with copying data from a text file.

From: Paul Lambert <paul(dot)lambert(at)autoledgers(dot)com(dot)au>
To: Andrej Ricnik-Bay <andrej(dot)groups(at)gmail(dot)com>
Cc: Phillip Smith <phillip(dot)smith(at)weatherbeeta(dot)com(dot)au>, pgsql-sql(at)postgresql(dot)org
Subject: Re: Issue with copying data from a text file.
Date: 2007-03-20 02:59:06
Message-ID: 45FF4DFA.1020202@autoledgers.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Andrej Ricnik-Bay wrote:
> On 3/20/07, Paul Lambert <paul(dot)lambert(at)autoledgers(dot)com(dot)au> wrote:
>
>> The source file comes from extracts on our main application which sits
>> inside an in-house pretending-to-be-a-dbms file system. The content of
>> these extracts would be difficult to change - the extract program would
>> need to parse the data looking for quotes and preceed them with the
>> necessary escape character.
>>
>> Not being a proper database dump it's not a simple matter of flicking a
>> switch to get it to include the escape character. The way the extracts
>> are written would require a few dozen lines of code to each extract, and
>> theres about 40ish extracts.
>>
>> Plus I don't maintain that side of our code, and those that do can be a
>> bit lazy and I'd likely be waiting months to get it done - if they even
>> decide to do it.
> Pipe it through sed and replace the Carets with TABS?
> sed 's/^/\t/g' c:/temp/autodrs_deal_lines.txt >
> c:/temp/autodrs_deal_lines.tab
>
> Then use copy like so:
> \copy table from 'c:/temp/autodrs_deal_lines.tab' delimiter E'\t' null ''
>
>
> Cheers,
> Andrej
>
>

The data contains tabs... don't ask why... I don't have a clue :P

I'll do something along the lines of sed... but not with sed, I'll use
the command line interpreter on the OpenVMS systems where the extracts
run. I just thought there might have been a quicker way to switch it off
in the copy command, i.e. specifying "quote none" as one of the
parameters to the command. I guess not...

Thanks for the pointers.

P.

--
Paul Lambert
Database Administrator
AutoLedgers

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Phillip Smith 2007-03-20 03:05:24 Re: Issue with copying data from a text file.
Previous Message Andrej Ricnik-Bay 2007-03-20 02:53:04 Re: Issue with copying data from a text file.