Hi
I am trying to edit a csv file. Bacically I need to input a search variable and the value that must be changed in one of the fields corresponding to that searched variable.
My csv file looks like so:
1,1A,5
1,1B,2
1,1C,3
2,2A,7
2,2B,4
2,2C,0
3,3A,1
3,3B,6
3,3C,4
I want to input a value for the second field (these are unique) and input a new value for the third field.
Example, If I input 1A and 2, then the new value of 2 must be written to the file and replace 5.
This is my awk file:
BEGIN {
FS=","
}
{
if (cellid == $2)
print "old parameter value was: " $3 " " $2 " new value is now " newvalue;
} print $3=newvalue>ds_pl_cell1.csv;
And from my command line, I call this:
awk -v "cellid=1A" -v "newvalue=0" -f changefile.awk ds_pl_cell.csv >ds_pl_cell1.csv
Please can you help as I am very new to this.
Thank you.