This section describes techniques to standardize text values in your datasets. You can use the following techniques to address some common issues you might encounter in the standardization of text and other non-numeric values.
For manipulation of individual values, it is often easiest to work with the String data type, which is the most flexible. Depending on your approach, you may choose to convert some of your columns into String type:
For more information, Valid Data Type Strings.
You can edit values in a column by applying one of the available string functions. The following transformation can be modified for any of the available string functions:
For more information see String Functions.
In the following example, you can see that there are minor differences between the String values in each row of the dataset. These differences are captured in the Description column.
|Base string: 'My String'|
|Base string + ' extra'|
| ||A space in front of base string|
|A space after base string|
|No space between the two words of base string|
|Two spaces between the two words of base string|
|Base string + a tab character|
|Base string + a return character|
|Base string + a newline character|
When this data is imported, it looks like the following, after minor cleanup:
Example data after import
To normalize these text values, you can use some of the techniques listed on this page to match the problematic string values in this dataset and correct them, as needed. The sections below outline a number of techniques for identifying matches and cleaning up your data.
NOTE: Before you begin matching data, you should perform a
When transforming strings, a key step is to trim off the whitespace at the beginning and ending of the string. For the above dataset, you can use the following command to remove these whitespaces:
The above transform uses the following special values, which are available for some transforms like
For the Columns textbox under Advanced, you can use this wildcard to reference all columns in the dataset.
|When multiple columns are referenced in a transform, this special value allows you to reference the source column in a replacement value.|
The previewed data looks like the following, in which five strings are modified and now match the base string:
Trim data to improve matches
Tip: To remove all whitespace, including spaces in between, you can use the
The platform language, , provides presets to identify missing or mismatched values in a selection of data.
Tip: In a column's histogram, click the missing or mismatched categories to trigger a set of suggestions.
Missing values preset: The following transform replaces missing URL values with the text string
ISMISSING([Primary_WebSite_or_URL]) identifies the rows missing data in the specified column:
For more information, see Find Missing Data.
NOTE: If the data type for the column is URL, then the replacement text string must be a valid URL, or the new data is registered as mismatched with the data type.
Mismatched values preset: This transform converts to
00000 all values in the
Zip column that are mismatched against the
Zipcode data type. In this case, the preset
ISMISMATCHED(Zip, ['Zipcode']) identifies the mismatched values in the column, as compared to the
Zipcode data type:
For more information, see Find Bad Data.
An entry in the example data contains an additional word:
My String extra. You can use a simple replace command to remove it:
global parameter causes the replacement to be applied to all instances found within a cell value. Otherwise, the replacement occurs only on the first instance.
There are multiple ways of removing double spaces, or any pattern, from text values. For best results, you should limit this change to individual columns.
NOTE: For matching string patterns that are short in length, you should be careful to define the scope of match. For example, to remove double spaces from your dataset, you should limit the columns to just the ones containing string values. If you applied the change to all columns in the dataset, meaningful uses of double spacing could be corrupted, such as in JSON data fields.
In the above, the Find term contains a string with two spaces in it.
Tip: If you wish to find two or more spaces, you can use the following in the Find parameter:
CamelCase refers to text in which multiple words are joined together by removing the spaces between them. In the example data, the entry
MyString is an example of CamelCase.
NOTE: Regular expressions are very powerful pattern-matching tools. If they are poorly specified in a transform, they can have unexpected results. Please use them with caution.
You can use to break up CamelCase entries in a column of values. The following transforms use regular expressions to identify patterns in a set of values:
The first transform locates all instances of uppercase letters followed by lower-case letters. Each instance is replaced by a space, followed by the found string (
$2). For more information, see Text Matching.
Remove last word:
For example, you need to remove the last word of a string and the space before it. You can use the following
replace transform to do that:
When the above is previewed, however, you might notice that ending punctuation is not captured. For example, periods, exclamation points, and question marks at the end of your values are not captured in the . To capture those values, the Find parameter must be expanded:
In the second version, a capture group has been inserted in the middle of the
on parameter value, as specified by the contents of the parentheses:
|) denotes a logical OR, meaning that the specified individual characters could appear or the value after the vertical pipe.
Reduce total number of words:
You need to cut each value in a column down to a maximum of two words. You can use the following to identify the first two words using capture groups in a and then write that pattern back out, dropping the remainder of the column value:
For the Find pattern:
startpattern identifies the start of each value in the
alphacapture groups identify the first two words in the string. Note that the space after the second capture group is specified outside of the capture group; if it was part of the capture group, a trailing space is written in the replacement value.
anycaptures any single character.
anycharacter and the
endof the value.
You can trim out whitespace from an individual column via transformation. The
TRIM function applied to string values removes the leading and trailing whitespace:
To apply this function across all columns in the dataset, you can use the following:
Allabove, you can use the asterisk (
*) wildcard, which represents all possible value. In this case, both values for Columns matches with all column names in the dataset.
$colentry denotes a reference to the current column. So for any column to which this transformation is applied, the source values are pulled from the column itself and then trimmed.
In some cases, you may wish to remove all spaces, including those in between words or digits, in your strings:
If needed, you can remove all whitespace from a column of values.
NOTE: This transformation differs from the
Tip: For some of the string comparison functions, you may achieve better results by comparing strings without whitespace.
The following transformation removes all non-alphanumeric symbols from your string values, including:
NOTE: Accented characters may not be removed. If this function fails to remove specific symbols, you may need to remove these symbols manually or change the input encoding on the dataset through the Import Data page.
The following transformation converts all accented characters (e.g."ä") to unaccented characters (e.g "a").
When some files are imported into the application, leading and trailing quotes may remain for some or all columns. You can use the following transformation to remove these quotes from all columns:
NOTE: Quotes that appear in the middle of the string value are not removed. Single quotes, such as apostrophes, are not removed.
You can add fixed-string prefixes or suffixes to your string values. The following adds
-0000 to a text version of the Zipcode column:
You can use the following steps to set all text values in a column to be the same case.
Proper (sentence) case:
If you need all of your column values to be of the same length, one technique is to pad each string value at the front sufficiently, such that all string lengths in the column are identical.
This transformation results in adding enough spaces to each row value until the length of each value is 50 characters.
NOTE: Strings that are longer that the prescribed maximum are unchanged. You can use the
You can limit the maximum size of a column or set of columns to a fixed string length. For example:
In the above, if the length of either column is longer than 32 characters, then the column value is set to the leftmost 32 characters. For shorter strings, the entire string is used.
For more information, see Manage String Lengths.
You can use the following functions to locate values within your strings. These functions can be used as part of New Formula or Edit Formula transformations to create or edit column content:
After modifying non-text values as strings, remember to convert them back to their original types.