Re: Importing lines of variable length from ASCII

From: Andrej <andrej(dot)groups(at)gmail(dot)com>
To: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Importing lines of variable length from ASCII
Date: 2010-02-25 20:35:59
Message-ID: b35603931002251235j12a86ff6gd5ccd0437b0f4fce@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On 26 February 2010 00:52, A. Kretschmer
<andreas(dot)kretschmer(at)schollglas(dot)com> wrote:
> kretschmer(at)tux:~$ cat file.txt | awk '{cols=split($0,a,"|"); if (cols==4) print $0; else printf ("%s|\n",$0)}'

Slightly shorter variant:
awk -F'|' '{if(NF<4){print $0"|"}else{print $0}}' file.txt

> Regards, Andreas

Cheers,
Andrej

--
Please don't top post, and don't use HTML e-Mail :} Make your quotes concise.

http://www.american.edu/econ/notes/htmlmail.htm

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Mary Anderson 2010-02-26 01:11:41 How many columns can I have in an ORDER BY clause?
Previous Message Andreas Kretschmer 2010-02-25 18:18:26 Re: Leap Years