±add
Inserts or appends one or more fields (columns) to the CSV data row
Adds one or more new columns next to an existing column of the data row, and optionally fills each of them with a value.
The value can be a literal, the contents of another field, or any expression.
If you want to insert the new column at a specific position, you must denote the existing column the new column shall be inserted before (or after).
If you want to append one or more columns at the end of the data row instead, then just leave off this reference.
Inserting a single Column
Inserts a new column next to an existing column of the data row, and optionally fills it with a value.Pattern
±add[NewFieldName]@[ExistingFieldname]
±add[NewFieldName]@[ExistingFieldname]=NewFieldValue
Usage Examples
If there is a csv file:
Product | Product Weight |
---|---|
Apple | 100g |
Pear | 120g |
- -add["Transport Weight"]={(1,05*["Product Weight"]),3}g
- Appends a new column
Transport Weight to the data row, and fills it with the value of the fieldProduct Weight * 1.05. The output shall be with decimal comma and 3 decimal places.
Hint: On the command line, the quotes are necessary because of the whitespace in the column names. When using a %job file, they can be omitted.
Now we have the csv table:
Product | Product Weight | Transport Weight |
---|---|---|
Apple | 100g | 105,000g |
Pear | 120g | 126,000g |
Banana | 200g | 210,000g |
- -add["Product ID"]@["Product Weight"]
- Inserts a new empty column "Product ID" before the column "Product Weight". A subsequent field command can later be used to fill it with a value.
Product | Product ID | Product Weight | Transport Weight |
---|---|---|---|
Apple | 100g | 105,000g | |
Pear | 120g | 126,000g | |
Banana | 200g | 210,000g |
More examples
- -add["Line Number"]@[1]=(#)
- Inserts a new first column "Line Number" before the recent first column, and initializes it with the current data row number.