Re: dbaccess output formatting
Posted in 1998
Mike Morris writes:
>
> Hello!
>
> As a new user to Informix, I wonder if there are any tools for
> formatting the output
> of dbaccess selects to make rows easier to read (spreadsheet-like)?
If you don't include blobs in your select this should work:
(dbaccess tracsy ist.sql; echo "") |
sed '
1,3d
s/^[^ ]* */"/
:join
/\\n$/b endline
s/\\n[^ ]* */","/
N;
b join
:endline
s/\\n$/"/g'
# (dbaccess tracsy ist.sql; echo "") |
### Run your script, append a blank line at the end
# sed ' ### sed script to convert output to CSV format:
# 1,3d ### Remove the 3 blank lines at the start of the output
# s/^[^ ]* */"/ ### Replace the first column name (plus blanks) with '"'
# :join ### Label
# /\\n$/b endline ### If we have joined an empty line to the end of the
# ### pattern space, then branch to "endline"
# s/\\n[^ ]* */","/ ### Replace the embedded newline & the column name
# ### (plus blanks) with '","'
# N; ### Join the next line of input to the pattern space
# b join ### Branch back to "join"
# :endline ### Label
#s/\\n$/"/g' ### Done line, replace the embedded newline at the
### end of the line with '"', line will now print
--
______________________________________________________________________
| Colin McGrath cmm@trac3000.ueci.com |
| Raytheon Engineers & Constructors, Inc. (215) 422-4144 |
| Phila, PA, USA |
| Any opinions I state are my own and not necessarily of my employer |
|____________________________________________________________________|