Re: Need help for import of text file - Mailing list pgsql-general

From Andreas
Subject Re: Need help for import of text file
Date
Msg-id 50CE0973.8060003@gmx.net
Whole thread Raw
In response to Re: Need help for import of text file  (Peter Bex <Peter.Bex@xs4all.nl>)
Responses Re: Need help for import of text file
List pgsql-general
Am 15.12.2012 22:22, schrieb Peter Bex:
On Sat, Dec 15, 2012 at 10:16:55PM +0100, Peter Bex wrote:
A simple sed(1) expression should do the trick:

sed -E 's/ +/ /g' old-file > new-file
I just remembered where I could check, and the GNU sed equivalent is:

sed -r 's/ +/ /g' old-file > new-file

Sorry for the confusion.


With sed as startingpoint I figured it out.
Those 3 steps make the input files consumable for COPY
  1. dos2unix
  2. sed -i 's/[ \t]*$//'
  3. sed -i 's/  / /g'


The input files get created by a simple windows batch where I can't change anything.
It uses echo to attach a line of 4 parameters to those textfiles.

How would you manage if one or more of those parameters contained blanks in some cases?
This doesn't appear, yet. But I consider this as luck.   :}

The real column formats are ( TEXT, TEXT, DATE, TIME ).

pgsql-general by date:

Previous
From: Andres Freund
Date:
Subject: Re: Default timezone changes in 9.1
Next
From: Tom Lane
Date:
Subject: Re: Authenticate with hash instead of plaintext password?