table correct headers, table correct headers ignore case
This function helps to correct or align column header names and is particularly useful for tables originating from different sources where
wordings or spellings of header names show slight differences and you want to harmonize them easily be correcting them. The functions described
here differ from table rename headers() in the 2nd parameter: Instead of specifying specific columns, comparison patterns are used to check
all headers from left to right until the first match is found.
The function name table correct headers ignore case ignore case sensitivity while comparing headers with comparison patterns provided.
No exceptions are asserted if a comparison of a matching pattern with the table headers results in no matches.
Note: This function supports wildcard symbols if the strings used for comparison patterns are softquoted, i.e. using single quotation marks.
Indirect parameter passing is disabled
3
No. | Type | Description |
---|---|---|
1 input |
string | Name of existing table |
2 input |
set or string | Existing header name(s) or column number(s) Specify the comparison patterns.
|
3 input |
set or string | New header name(s) List the new header names corresponding to the existing ones specified in the previous function parameter. |
Type | Description |
---|---|
numeral | Number of corrections accomplished |
Table not found
number of comparison pattersn and new headers is inconsistent
table initialize ( table, { { first name, Lastname, Phone No, Age }, { Jim, Archer, "1-212-555-1212", 28 } } );
count[] = table correct headers ignore case( table, {'Last*name', 'First*name', 'Family*' },
{ Last Name, First Name, Last Name } );
table list ( table );
echo;
echo("Number of headers corrected: ", count[]);
0 : First Name | Last Name | Phone No | Age
1 : Jim | Archer | 1-212-555-1212 | 28
Number of headers corrected: 2