newbie question on output formatting/"pretty" print

M

martin

Hi, I am trying to print to a file 3 columns of information, the first
row is the label field,
consisting of 3 strings, 9, 4, and 9 characters wide. The first column
is strings, the second and third are integrs, of 1 up to 14 digits
wide.

aaaaaaaaa bbbb ccccccccc
--------------- ------- ---------------
xxxxxxxx 1 43432
xxxxxxxx 3213213 435435435
so on

I tried with printf %s and %d (- and + options also) but since the
width of second and third columns varies widely, the result is not
appealing and it needs a lot of trial and error to get something
half-decent looking. And also there seems to be no center
justificiation option with
printf.

I am wondering is there a way to get a decent print display without
too much trial and error. and juggling of fields nad printf options.
Thanks. Martin
 
I

Ian Wilson

martin said:
Hi, I am trying to print to a file 3 columns of information, the first
row is the label field,
consisting of 3 strings, 9, 4, and 9 characters wide. The first column
is strings, the second and third are integrs, of 1 up to 14 digits
wide.

aaaaaaaaa bbbb ccccccccc
--------------- ------- ---------------
xxxxxxxx 1 43432
xxxxxxxx 3213213 435435435
so on

I tried with printf %s and %d (- and + options also) but since the
width of second and third columns varies widely, the result is not
appealing and it needs a lot of trial and error to get something
half-decent looking. And also there seems to be no center
justificiation option with
printf.

I am wondering is there a way to get a decent print display without
too much trial and error. and juggling of fields nad printf options.

I still have a soft spot for Perl's "write" function, which handles
centering and column-wrap nicely.
(see `perldoc perlform`)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top