table insert columns, table insert missing columns
This function inserts one or more columns into the table with initial values.
table insert missing columns will only insert and initialize columns if they are missing. If they exist, then they will not be touched or the contents being initialized.
Indirect parameter passing is disabled
2 -4
No. | Type | Description |
---|---|---|
1. input |
string | Name of existing table |
2 input |
table columns | Header names columns to add See table columns as function parameters for general ruling for this parameter.
|
Opt. 3 input |
set or string | Initial Values If this set contains more values than in 2nd argument, then the excess values will be discarded. If this set contains less values, then the first value will be referred after the last one (modulo pattern). If the parameter is blank, or missing, then the columns will be initialized with blanks. |
opt. 4 input |
table column | Destination column See table columns as function parameters for general ruling for this parameter.
The new column will be inserted to the left. To insert them to the right, using shifted Table Column Specifications is a possible option, or use column numbers. Negative indexing is supported, where -1 adds the new column after (and not before) the last column. |
Type | Description |
---|---|
numeral | Number of headers inserted -1 is returned if no header row has been found |
Table not found
table initialize( t,
{ { First Name, Last Name, Given Name, Birth Year },
{ Abel, Adams, A., 1990 },
{ Betty, Beavers, B., 1995 },
{ Charlie, Collins, C., 2000 },
{ Daniela, Douglas, D., 2005 } } );
table insert columns( t, Gender, "M or F", First Name );
table insert columns( t, Phone, {"1-202...", "1-212..."}, '>First Name' );
table insert columns( t, Birthplace, "-", -1 );
count[] = table insert missing columns( t, {Birthplace, Street} );
echo(count[]); // Inserted 1 additional column.
table list ( t );
1
0 : Gender | First Name | Phone | Last Name | Given Name | Birth Year | Birthplace | Street
1 : M or F | Abel | 1-202... | Adams | A. | 1990 | - |
2 : M or F | Betty | 1-202... | Beavers | B. | 1995 | - |
3 : M or F | Charlie | 1-202... | Collins | C. | 2000 | - |
4 : M or F | Daniela | 1-202... | Douglas | D. | 2005 | - |