...
You can generalize this formatting across multiple columns by applying the $col
reference in the transform's function, as in the following:
d- |
---|
...
trans | ||||||
---|---|---|---|---|---|---|
|
...
|
See Column Details Panel.
...
- In the data grid, select an instance of " kg". Note that the space should be selected, too.
- Among the suggestion cards, select the Replace card.
- It should automatically choose to replace with nothing, effectively deleting the content. To check, click Modify.
The transform should look like the following:
coded- hideNote true replace col: Weight_kg on: ` kg` with: '' global: true
trans p03Value '' Type step p01Name Column p01Value Weight_kg p02Name Find p02Value ' kg' p03Name Replace with p04Value true p04Name Match all occurrences SearchTerm Replace text or patterns - Add it to your recipe.
- Verify that the column's data type has been changed to
Integer
orDecimal
, depending on the values in it.
...
To normalize to English units, the first issue is easily corrected by multiplying the Weight values by 2.2, since 1 kg = 2.2 lb:
d- |
---|
...
hideNote | true |
---|
...
trans | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
If you want to round the value to the nearest integer, use the following:
d- |
---|
...
hideNote | true |
---|
...
trans | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
After the above is added to the recipe, you should rename the column: Weight_lbs
.
...
- Select the first quote mark in one of the entries.
- In the suggestion cards, select the Replace card.
Select the variant that deletes all quotes in the column.
The full command should look like the following:
coded- hideNote true replace col: Height_ft on: `"` with: '' global: true
trans p03Value '' Type step p01Name Column p01Value Height_ft p02Name Find p02Value `"` p03Name Replace with p04Value true p04Name Match all occurrences SearchTerm Replace text or patterns - Add it to your recipe.
- The remaining steps compute the number of inches. Multiply the feet by 12, and then add the number of inches, using new columns of data.
- Select the single quote mark, and choose the Split suggestion card. This transform step should split the column into two columns:
Height_ft1
andHeight_ft2
. Derive the value in inches:
coded- derive type:single value:Rename the new column:hideNote true Height_in
.trans p03Value Height_in Type step p01Name Formula type p01Value Single row formula p02Name Formula p02Value ((Height_ft1 *12)+Height_ft2) - Add it to your recipe.
p03Name New column name SearchTerm New formula - You can drop the other, interim columns.
...
If you have inconsistent units within a column, it might be possible to correct these values by applying a multiple. For example, you might be able to determine that some values are in kilometers, instead of meters, based on their much smaller values. Multiplying the kilometer values by 1000 should standardize your units. The following multiplies all values in the column Distance
that are less than 1000 by 1000.
d- |
---|
...
hideNote | true |
---|
...
trans | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
...
|
...
|
Note the implied assumption that there are no distances in kilometers that are over 1000.
...
You can use the following transforms to perform rounding functions within these columns:
d- |
---|
...
hideNote | true |
---|
...
trans | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
d- |
---|
...
hideNote | true |
---|
...
trans | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Info |
---|
NOTE: The above assumes that the number of significant digits remains fixed in the source data. If this varies over times or uses of the transform recipe, you might need to revisit these specific transform steps. |
...