table read column selected rows

Prev Next

Function Names

table read column selected rows

Description

This function extracts a column from the table and places the values in the set from the selected rows where the calculated expression returns true. All blank or non-existing entries will be translated to blank strings. Automatic type conversion (e.g. numbers to numerals) can be adjusted with the table configure() function.

Call as: function

Restrictions

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

Parameter count

3

Parameters

No.TypeDescription
1.
input
string Name of existing table

2.
input
table column Existing column

See table columns as function parameters for general ruling for this parameter.
Specific rules apply for this function:

  • Only 1 header name or column number may be specified.

3.
code
expression
:string
Expression to select rows

Specify the conditions or rules to select the rows. See expressions to select rows.
The table context for partial table specifications is available for referencing just the columns easily. Example: [Year]>=2022.
Attention: Comparison operators = and <> (instead of == and !=) may hijack the next function parameters for its own use as additional comparison operands, e.g. a[]=1,3,5. As long this comparison is not made in the last function parameter, then put parentheses around them, e.g. ... , (a[]=1,3,5), ....

Return value

TypeDescription
set Retrieved data

Data from the different rows in the same column.

Examples

       table initialize ( table 1, { { Animal, leg count },
               { Worm,  0}, { Bird, 2 }, { Dog, 4 }, { Fly, 6 }, { Tick, 8 } } );

       echo( table read column selected rows( table 1, Animal, [leg count]>4 ) );
       echo( table read column selected rows( table 1, leg count, [leg count]>4 ) );

       // Numbers are read as numerals. Force reading them as strings:

       table configure( table 1, read numerals, no );

       // Pay attention to convert leg counts into nuemrals here.
       echo( table read column selected rows( table 1, leg count, num([leg count])>4 ) );

Output

{'Fly','Tick'}
{6,8}
{'6','8'}
Try it yourself: Open LIB_Function_table_read_column_selected_rows.b4p in B4P_Examples.zip. Decompress before use.

See also

table write column selected rows