table list

Prev Next

Function Names

table list

Library

Support Library

Description

This function lists the entire table or selected rows and columns of a table on standard output (for example the console). Since this function does not make use of any fancy I/O features, listing tables can also be integerated in B4P programs running in batch mode in order to provide some more visibility.

Hint: This function is suitable for interactive and debugging use in order to inspect tables conveniently.

Call as: procedure

Restrictions

Indirect parameter passing is disabled
Under normal conditions, the 'Support Library' is loaded automatically, so no 'include(...)' call is needed.

Parameter count

1, 3, 5, ...

Parameters

No.TypeDescription
1.
input
string Name of existing table

2., 4., ...
input
string Option

Following options are supported:

1st row Specify first row number to list (e.g. 2 = begin with row 2). The header row (row 0) will always be displayed.
last row Specify last row number to list
1st col Specify first column number to list. Column numbering begins with 0, not 1.
last col Specify last column number to list.
briefly Specify top n and bottom n rows to list, skipping the ones in the middle (if any left).

3., 5., ...
input
numeral Value

This is the value associated to the option in the previous function parameter.
Negative indexing is supported for specifying rows (-1 = last row) and columns (-1 = last column acc. to widest row in the whole table).

Examples

  table load ( t, "Examples\Cities.csv" );

  // Begin with row 2, skip last 3 columns, and for the rows to list, list only the first and last 3 of them.
  table list ( t, 1st row, 2, briefly, 3, last col, -3 );

Output

    0 : Country | City         | State/Province | Inhabitants | Famous attraction | Alt. (m)
    2 : USA     | Washington   | D.C.           | 650000      | Lincoln Statue    | 7       
    3 : USA     | Philadelphia | Pennsylvania   | 1500000     | Independence hall | 12      
    4 : USA     | Boston       | Massachusetts  | 620000      | Freedom trail     | 43      
  ... :
   12 : SWI     | Zürich       | Kt. Zürich     | 404000      | Street Parade     | 408     
   13 : FRA     | Paris        | Île de France  | 2240000     | Eiffel Tower      |         
   14 : SWI     | Davos        | Grisons        | 11000       | Weissfluhgipfel   | 1650    

Try it yourself: Open LIB_Function_table_list.b4p in B4P_Examples.zip. Decompress before use.

See also

view
list tables