# change-column-case

## Description

<mark style="color:purple;">`change-column-case`</mark> *adaptor converts the case of text values in a datatable column to a specified format.*

The list of supported case patterns are:

* `camel case`: text with the separator denoted by the next word capitalised.\
  `OfMice and men` → `ofMiceAndMen`
* `capital case`: space separated text with each word capitalised.\
  `OfMice and men` → `Of Mice And Men`
* `constant case`: upper case text with an underscore between words.\
  `OfMice and men` → `OF_MICE_AND_MEN`
* `dot case`: lower case string with a period between words.\
  `OfMice and men` → `of.mice.and.men`
* `header case`: dash separated string of capitalised words.\
  `OfMice and men` → `Of-Mice-And-Men`
* `hyphen case`: lower cased string with dashes between words (same as kebab case).\
  `OfMice and men` → `of-mice-and-men`
* `kebab case`: lower cased string with dashes between words (same as hyphen case).\
  `OfMice and men` → `of-mice-and-men`
* `lower case`: text with all letters lower case.\
  `OfMice and men` → `ofmice and men`
* `no case`: lower cased string with spaces between words.\
  `OfMice and men` → `of mice and men`
* `param case`: lower cased string with dashes between words (same as kebab case).\
  `OfMice and men` → `of-mice-and-men`
* `pascal case`: string of capitalised words without separators.\
  `OfMice and men` → `OfMiceAndMen`
* `path case`: lower case string with slashes between words.\
  `OfMice and men` → `of/mice/and/men`
* `sentence case`: lower case with spaces between words and capitalised first letter.\
  `OfMice and men` → `Of mice and men`
* `snake case`: lower case string with underscores between words.\
  `OfMice and men` → `of_mice_and_men`
* `sponge case`: string with random capitalisation applied.\
  `OfMice and men` → `oFmiCe anD mEN`
* `swap case`: swaps every character from upper to lower case, or lower to upper case.\
  `OfMice and men` → `oFmICE AND MEN`
* `title case`: a mixed-case style following English language rules.\
  `OfMice and men` → `OfMice and Men`
* `upper case`: text with all letters upper case.\
  `OfMice and men` → `OFMICE AND MEN`

## Inputs

**`data`**\
Type: `datatable`\
Required: Yes\
The datatable containing the column to be converted.

**`column`**\
Type: `text`\
Required: Yes\
The column to be converted.

**`case`**\
Type: `text`\
Required: Yes\
One of the supported case patterns.

## Outputs

**`data`**\
Type: `datatable`\
A datatable with target column added.

## Examples

### Example 1: Standardize values in a column.

#### Inputs:

`data`:

| Sample ID | Sex    |
| --------- | ------ |
| Sample A  | female |
| Sample B  | MALE   |
| Sample C  | male   |
| Sample D  | Female |
| Sample E  | FEMALE |
| Sample F  | Male   |

`column`: Sex

`case`: upper case

#### Outputs:

`data`:

| Sample ID | Sex    |
| --------- | ------ |
| Sample A  | FEMALE |
| Sample B  | MALE   |
| Sample C  | MALE   |
| Sample D  | FEMALE |
| Sample E  | FEMALE |
| Sample F  | MALE   |

-> Standardized the values in column `Sex` by converting it to uppercase.

## Use Cases

* In categorical variables, changing the case can be part of the process of converting data to a consistent format so certain variables can be treated as the same category regardless of case, aiding in data visualisation.
* When comparing or matching strings, it's often beneficial to have consistent cases
* In the process of cleaning and preprocessing data, changing the cases can help identify and handle duplicates more effectively. It aids in detecting and merging records that might have the same information but with different capitalization.
* Standardizing cases is essential for proper sorting and grouping of data. Without consistent cases, sorting operations may not produce the desired order, and groupings may not capture all similar items due to case variations.
