How do I create a column that depends on other columns or rows?

The JavaScript engine in the Replace feature allows you to calculate and output derived values based on other columns and rows.

As an example, let’s say that we have the following CSV file and we want to create a column that equals first column + 5.

1
2
3
  1. Create a second column by right-clicking on the column header and selecting Insert Column Right.
    Column header context menu
  2. Go to Search | Replace… (Ctrl + H) and enter the following:
    • In Find, enter .* to match any string.
    • Change the radio button to Regular Expressions.
    • In Replace with, enter \J Number(cell(-1)) + 5. The \J prefix indicates that this is a JavaScript expression. The expression takes the column on the left and adds 5. For more info about the cell function, see Replacement Expression Syntax.
    • Check In the Selection Only so that we only change column 2.
  3. Select column 2.
  4. Click on Replace All. The result is shown in the screenshot below.

Replace

For an example involving date calculations, read the answer to How To Get The Number Of Days Between Two Dates In Emeditor.