Re: Need help for import of text file
От | Andreas |
---|---|
Тема | Re: Need help for import of text file |
Дата | |
Msg-id | 50CE0973.8060003@gmx.net обсуждение исходный текст |
Ответ на | Re: Need help for import of text file (Peter Bex <Peter.Bex@xs4all.nl>) |
Ответы |
Re: Need help for import of text file
|
Список | 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-fileI 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
- dos2unix
- sed -i 's/[ \t]*$//'
- 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 по дате отправления: