JREPL Replace Values in One Column Only in a CSV

140 Views Asked by At

I am using JREPL (which is a very fast tool by the way) to search through a large CSV file and then replace some text in the file. However I ma running into a problem, whereby I only want to replace the values in the very first column of my file, not all columns

Here is the code that works:

type "DataminerFile.csv" | jrepl "01" "10" | jrepl "02" "20" | jrepl "03" "30" | jrepl "04" "40" > output.csv

I have tried this snippet in all the replacements, but it errors.

jrepl "02^{A1}"

Here is the structure of the CSV file

"01","GL","GENERAL LEDGER","*",88888,"MD/FI COMMENT ?"
"01","CONT01","CONTINENTAL NH3 PRODUCTS","A-BVT-RK",4,"REPAIR KIT FOR"
"03","CONT01","CONTINENTAL NH3 PRODUCTS","A-BVT-RK",1,"REPAIR KIT FOR"

So in column one, if the value is "01" I want to replace this to "10" but not touch column two.

1

There are 1 best solutions below

0
Matthew Colley On

If anyone stumbles across this from Google or whatever the hell we call it in the future (great brain hive??) Here is what fixed my problem. I enclosed my search parameters in a \b

type "DataminerFile.csv" | jrepl "\b01\b" "10" | jrepl "\b02\b" "20" | jrepl "\b03\b" "30" | jrepl "\b04\b" "40" > output.csv