print_list

Package: WA2L/edrc 1.5.57
Section: Library Commands (3)
Updated: 11 January 2009
Index Return to Main Contents

 

NAME

print_list - format CSV data to a list with dynamic column widths

 

SYNOPSIS

edrc/lib/print_list [ -h ]

print_list [ "field_separator" [ indent ]]

 

AVAILABILITY

WA2L/edrc

 

DESCRIPTION

the intention of this command is to print a list to a terminal in a good readable format. A CSV data provided via pipe from stdin is formatted and printed to stdout.

The first row is treated as header row. The width of all columns is dynamically adjusted to the row containing the longest column entry.

Text columns are aligned to the left, bare number columns are aligned to the right.

Furthermore the output is limited to the current terminal width if the environment variable $PRINT_FIT2WIDTH is not set to False.

To select named columns from the CSV data prior to the formatting of the list with print_list use select_columns(3).

 

OPTIONS

-h
usage message.

"field_separator"
field separator. If not specified, the default field separator is the semicolon ( ; ).

indent
left indent of the output in characters. If not specified the output is not indented.

 

ENVIRONMENT

$PRINT_FIT2WIDTH
If this environment variable is not set to False, the output is limited to the current width of the terminal window and rows extending the window width are marked with '>>'.

 

EXIT STATUS

0
no error.

4
usage displayed.

 

FILES

-

 

EXAMPLES

1) print CSV data as formatted list

The following CSV data received via pipe

  cat<<EOM | print_list
  ZIP;CITY;STATE;CNT;COUNTRY
  93117;Goleta;CA;USA;United States of America
  8222;Beringen;SH;CH;Switzerland
  8005;Cape Town;WC;RSA;South Africa
  EOM

results in the output:

  ZIP    CITY       STATE  CNT  COUNTRY
  -----  ---------  -----  ---  ------------------------
  93117  Goleta     CA     USA  United States of America
   8222  Beringen   SH     CH   Switzerland
   8005  Cape Town  WC     RSA  South Africa
  (3)

2) print selected columns of CSV data as formatted list

The columns CNT, ZIP and CITY of the CSV data are selected using the select_columns(3) command and then formatted to a list using the print_list command

  cat<<EOM | select_columns ";" "CNT;ZIP;CITY" | print_list
  ZIP;CITY;STATE;CNT;COUNTRY
  93117;Goleta;CA;USA;United States of America
  8222;Beringen;SH;CH;Switzerland
  8005;Cape Town;WC;RSA;South Africa
  EOM


what will result in the output:


  CNT  ZIP    CITY
  ---  -----  ---------
  USA  93117  Goleta
  CH    8222  Beringen
  RSA   8005  Cape Town
  (3)

 

SEE ALSO

edrcintro(1), csv(3), csvcat(3), print_header(3), print_index(3), select_columns(3)

 

NOTES

The four commands print_header(3), select_columns(3), print_list(3) and print_index(3) provide the functionality to efficiently produce ASCII reports having an identical look.

 

BUGS

-

 

AUTHOR

print_list was developed by Christian Walther. Send suggestions and bug reports to wa2l@users.sourceforge.net . 

 

COPYRIGHT

Copyright © 2009 Christian Walther

This is free software; see edrc/doc/COPYING for copying conditions. There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


 

Index

NAME
SYNOPSIS
AVAILABILITY
DESCRIPTION
OPTIONS
ENVIRONMENT
EXIT STATUS
FILES
EXAMPLES
SEE ALSO
NOTES
BUGS
AUTHOR
COPYRIGHT

This document was created by man2html using the manual pages.
Time: 00:14:19 GMT, March 08, 2025