table process (selected) columns

Prev Next

Function Names

table process columns, table process selected columns

Description

The function table process columns iterates through all columns from left to right, similarly to for all table columns(__).
The function table process selected columns iterates through all columns from left to right and processes them, if the condition expression is true. This feature works very similarly as table process selected rows(), but in the horizontal direction from left to right.

The width of the header row does primarily determine the loop from left to right to process the columns. The loop may be extended if column numbers beyond the last header are specified.

For this function, the enabled partial table specifications also includes referencing the current column number by simply specifying a '.' (point) and you can use the function col() to retrieve the current column number.

Call as: procedure or function

Restrictions

Indirect parameter passing is disabled
This function provides a table context for partial table specifications with table name, row number and column number for selected function parameters

Parameter count

3-5

Parameters

No.TypeDescription
1.
input
string Name of existing table

2.
input
numeral Row number

The specified row number will be used as current row when executing expressions and statements below using partial table specificatiions.

Opt. 3.
code
expression
:string
Expression to select columns

Applicable to table process selected columnss only:
Specify the conditions or rules to select the rows. See expressions to select columns.
You have the choice between boolean expressions (calculated for every column), a single column number or header name, or a parameter set containing column header names and/or numbers. Note that processing will always happen from left to right with all columns affected. It makes no differnce whether a column is referenced once or more.

The table context for partial table specifications is available for referencing just the columns easily. Example: [.]>=100.
Attention: If you are using comparison operators = and <> (instead of == and !=) which allow more than 1 operand on the righ hand side , then make sure you put the entire expression into parentheses. Otherwise the operators will hijack subsequent function parameters as part of their operands.

3. / 4.
code
statements
:string
Statements (applicable where columns are selected)

table process columns: The statements provided will be executed once for every column.
table process selected columns: The statements provided will be executed once for every column where the condition calculated before returned true.

The table context for partial table specifications is available for referencing just the columns easily. Example: [Full Name]=[First Name]+' '+[Last Name];.
Hint: If you encounter an error message at the very end of the program after you worked on a statement, you may proabably have forgotton to add the closing parentheses to close the function call.

5.
code
statements
:string
Statements (otherwise)

table process columns: Not applicable. This function accepts 3 parameters only. table process selected columns: The statements provided will be executed once for every cell in every row where the condition calculated for that row returned false.

The table context for partial table specifications is available for referencing just the columns easily. Example: [Full Name]=[First Name]+' '+[Last Name];.
Hint: If you encounter an error message at the very end of the program after you worked on a statement, you may proabably have forgotton to add the closing parentheses to close the function call.

Return value

TypeDescription
numeral Number of cells processed

With table process selected rows, the number of selected rows (and processed with statements from 3rd function parameter) are counted.

Examples


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

  table process columns          ( cities, 4, if (!is numeric([.])) [.] += '!' ); // ! after text items

  table process selected columns ( cities, 4, [.,0]=="City", [.] = +[.] ); // City upper case
  table process selected columns ( cities, 5, {0..2},        [.] = +[.] ); // Row 5, coluns 0..2 upper ase

  // Copies 'Little Mermaid' (next row below) from Copenhagen to Montréal
  table process selected columns ( cities, 6, 4,             [.] = [.,row()+1] );

  table list ( cities );

Output

    0 : Country | City          | State/Province | Inhabitants | Famous attraction | Alt. (m) | Famous cultural place | Moving along
    1 : USA     | New York City | New York       | 8300000     | St. of Liberty    | 10       | Guggenheim            | Taxi         
    2 : USA     | Washington    | D.C.           | 650000      | Lincoln Statue    | 7        | Smithsonian Inst.     | The Beast    
    3 : USA     | Philadelphia  | Pennsylvania   | 1500000     | Independence hall | 12       |                       | PCC streetcar
    4 : USA!    | BOSTON!       | Massachusetts! | 620000      | Freedom trail!    | 43       | !                     | Walking!     
    5 : USA     | SAN FRANCISCO | CALIFORNIA     | 805000      | Golden Gate       | 16       | SFMOMA                | Cable car    
    6 : CAN     | Montréal      | Quebec         | 1700000     | Little Mermaid    |          | Rialto Theater        | Skidoo       
    7 : DAN     | Copenhagen    | Hovedstaten    | 580000      | Little Mermaid    | 24       | Royal Theater         | Bicycle      
    8 : ITA     | Venice        | Venetia        | 260000      | Doge's Palace     | 1        | Theatro la Fenice     | Gondola      
    9 : USA     | Los Angeles   | California     | 3800000     | Hollywood         | 100      | Getty Center          | Car          
   10 : AUT     | Vienna        |                | 1800000     | Prater            |          | Opera                 | Fiacre       
   11 : THA     | Bangkok       |                | 8250000     | Wat Phra Kaeo     | 5        | National Museum       | Longtail boat
   12 : SWI     | Zürich        | Kt. Zürich     | 404000      | Street Parade     | 408      | Kunsthaus             | Tram         
   13 : FRA     | Paris         | Île de France  | 2240000     | Eiffel Tower      |          | Louvre                | Métro        
   14 : SWI     | Davos         | Grisons        | 11000       | Weissfluhgipfel   | 1650     | Kirchner Museum       | Ski lift     

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

See also

table process rows
table process selected rows
table process cells
table process cells selected rows