I have a question about Excel-if-function implementation with AWK. I have a csv file having eight columns like below:
3,3,1,2,2,4,1,3
3,4,2,4,2,5,4,1
3,2,1,1,6,5,4,3
Each field can take only integer values from 1 to 6. I would like to give one point if the first column is 1. In other cases, the score would be zero. In this MWE case, the point for all three row is zero because everyone answered as 3, not 1. If I wish to do this with MS Excel, I usually insert one column next to the first column and write a function like =IF(A1=1,1,0). And then, by repeating this procedures for all the eight columns, I can calculate the total score by summing up all the inserted columns. I wonder how I can implement this type of function with awk. Thanks in advance for any advice.
Aucun commentaire:
Enregistrer un commentaire