Task
A table has weight in grams, sometimes with a suffix such as g. The final field must contain weight in kilograms.
Short Answer
In weight_kg, keep the numeric part with a regex rule and then divide the value by 1000.
How to Do It in Eofferix
- Create the final
weight_kgcolumn, use the source weight column, and open its settings.
The settings button is highlighted under the final weight_kg column. - In Transformations, add a rule: condition Regular expression, value
\d+(?:[,.]\d+)?, action Remove everything except. This step removes all characters from the string except digits, dots, and commas. - Add the second rule: condition Current value — Any, action Divide, value
1000.
In weight_kg settings, the numeric part is kept first and then divided by 1000. - Save the column settings.
Before / After
Before
source data| sku | weight_raw |
|---|---|
| SKU-1001 | 1250 g |
| SKU-1002 | 750 g |
After
result| sku | weight_kg |
|---|---|
| SKU-1001 | 1.25 |
| SKU-1002 | 0.75 |