Arranging Haphazard output in readable format

Dear Friends,
Need your help once again.

I have a sql to download output in pipe separated format.
Due to that output looks haphazard.

E.G.

$cat output.temp

123|456|789|0
67345123||3455|1
7124563|432343414||345324

By any was can we arrange it in tabular format for better readability?

Please guide me.

Thanks
Anu.

awk -F'|' '{for (i=1;i<=NF;i++){printf "%-20s", $i}}{printf "\n"}' file

one way is you can run your sql query to get the output in csv format. Or you can run a script on this output replace | with , and open the file in excel or any spreadsheet. That way you can see output in tabular format.

Or just try following and open the file into spreadsheet.

me@lappy:~/Documents/file$ cat tmp.txt
123|456|789|0
67345123|3455|1
7124563|432343414|345324
me@lappy:~/Documents/file$ sed -e s/\|/,/g tmp.txt 
123,456,789,0
67345123,3455,1
7124563,432343414,345324


Look if you have the column utility available on your system.

$ cat output.temp
123|456|789|0
67345123||3455|1
7124563|432343414||345324
$ column -nt -s'|' output.temp
123       456        789   0
67345123             3455  1
7124563   432343414        345324

Edit: the -n option is a Debian GNU/Linux extension, so maybe not available to you - your manpage will tell.

Hi.

Using the perl utility align on the data in file data1:

% align -s '/\|' -ar -j_ -g3 data1
     123         456    789        0
67345123               3455        1
 7124563   432343414          345324

One can select the field separation pattern as "|', the alignment is right, the output separation is done with space characters, and the gutter is 3 spaces, so that numbers can be easily compared. There are generally appropriate defaults for these, but you can change them if desired, as illustrated

See the page for details and download: align ? Freecode

Best wishes .. cheers, drl