I have a large .csv (comma separated, with over 90,000 rows), the format looks like this:
xcoord,m1,m2,m3 9,TRUE,FALSE,FALSE -1,TRUE,FALSE,FALSE 0,TRUE,FALSE,FALSE
I was able to add an extra column at the end with a header of AMT to allow writing to the last field:
Source_File="/test/Orders_ALL.csv" Output_File="/test/Orders_ALL_MODIFIED.csv" awk -v d="BMT" -F"," 'BEGIN { OFS = "," } {$5=d; print}' "$Source_File" > "$Output_File"
The output after the above yields:
xcoord,m1,m2,m3,BMT 9,TRUE,FALSE,FALSE,BMT -1,TRUE,FALSE,FALSE,BMT 0,TRUE,FALSE,FALSE,BMT
What I am trying accomplish, is to read the first column value starting from the 2nd row and onwards, if is less than 0 it will write the word "BEHIND", if is 0 than print the word "MID" and if is anything greater than 0, than print the word "THROUGH"
Here is the desired result:
xcoord,m1,m2,m3,BMT 9,TRUE,FALSE,FALSE,THROUGH -1,TRUE,FALSE,FALSE,BEHIND 0,TRUE,FALSE,FALSE,MID