table extend, table extend selected rows
This function extends the table by breaking up the contents in 1 or multiple columns into smaller items and distribute these items over
additional rows being inserted below. As an example, one field contains multiple values (numbers, text elements, etc) separated with commas
and need to be put into separate rows: 2,3,5,7,11 would create 4 additional rows and put the 5 indiviudal numbers into each of the rows.
When rows are inserted, all columns except those with data to be broken up will be duplicated.
Note: This function may only insert further rows. No rows are deleted in case the contents to break up are blank.
table extend covers all rows to extend where needed.
table extend selected rows covers the selected rows only.
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
2 - 5
No. | Type | Description |
---|---|---|
1. input |
string | Name of existing table |
Opt. 2. code |
expression :string |
Expression to select rows Applicable for table extend selected rows only. Specify the conditions or rules to select the rows. See expressions to select rows. |
2. / 3. input |
table columns | Columns with contents to be broken apart The contents in the specified columns will be broken apart and distributed across multiple rows after being inserted. All types are accepted: Numeric, text, dates, sets, etc. Following rules apply for multiple columns specified:
|
3. / 4. input |
string set |
Separator symbols In order to break up the contents in the specified columns, a separator symbol needs to be specified for each column. The separator symbol must
contain at least one character. Typical separator symbols could be comma, semicolon, new line, slashes, etc.
|
Opt. 4. / 5. input |
table columns | Existing columns to copy See table columns as function parameters for general ruling for this parameter.
Note: If the columns specified here are also selected as columns where data is to be broken apart, then the copying takes place before data is broken down. E.g. if 5 rows are inserted, but a the column breaks into 3 rows, then the remaining 2 rows contain the copies of the original contents. Default value: (None) |
Opt. 5. / 6. input |
table column | Index column See table columns as function parameters for general ruling for this parameter.
What will be written into the index column if n rows are inserted below or above: |
Type | Description |
---|---|
numeral | Number of rows identified Only the number of identified rows (and not the number of inserted rows) is returned. -1 is returned if table is empty. |
table initialize( base data, {
{ Name, Features 1, Features 2, Text, Numbers, Gender },
{ Nick, "Hi/He/Hu", "Me, You, He", ABCDE, 2, M },
{ Jane, "She/Her", "1, 01", A, 3, F },
{ Nobody, "", "", '', 0, ''},
{ Sophie, " He / She", "{ He , She }", SO, 1, F } } );
table copy table( base data, copy );
echo("Same, copy down Name and Features 1:");
a[] = table extend( base data,
{ Features 1, Features 2, Text, Numbers },
{ '/', '#set', '#chars', '#qty' }, {Name, Features 1} , Index );
table list( base data );
echo("Number of rows extended: ", a[], new line);
echo("Same, but copy all columns, count from zero, and Nick and Sophie only:");
a[] = table extend selected rows( copy, ([Name]=Nick,Sophie),
{ Features 1, Features 2, Text, Numbers },
{ '/', '#set', '#chars', '#zero' }, '*' , Index );
table list( copy );
echo("Number of rows extended: ", a[]);
Same, copy down Name and Features 1:
0 : Name | Features 1 | Features 2 | Text | Numbers | Gender | Index
1 : Nick | Hi | Me | A | 1 | M | 0
2 : Nick | He | You | B | 2 | | 1
3 : Nick | Hu | He | C | | | 2
4 : Nick | Hi/He/Hu | | D | | | 3
5 : Nick | Hi/He/Hu | | E | | | 4
6 : Jane | She | 1 | A | 1 | F | 0
7 : Jane | Her | 01 | | 2 | | 1
8 : Jane | She/Her | | | 3 | | 2
9 : Nobody | | | | 0 | | 0
10 : Sophie | He | He | S | 1 | F | 0
11 : Sophie | She | She | O | | | 1
Number of rows extended: 4
Same, but copy all columns, count from zero, and Nick and Sophie only:
0 : Name | Features 1 | Features 2 | Text | Numbers | Gender | Index
1 : Nick | Hi | Me | A | 0 | M | 0
2 : Nick | He | You | B | 1 | M | 1
3 : Nick | Hu | He | C | 2 | M | 2
4 : Nick | Hi/He/Hu | Me, You, He | D | 2 | M | 3
5 : Nick | Hi/He/Hu | Me, You, He | E | 2 | M | 4
6 : Jane | She/Her | 1, 01 | A | 3 | F |
7 : Nobody | | | | 0 | |
8 : Sophie | He | He | S | 0 | F | 0
9 : Sophie | She | She | O | 1 | F | 1
Number of rows extended: 2