Answer by Arjun Mathew Dan for AWK count number of times a term appear with...
Almost same as the other answer, but printing 0 instead of blank.AMD$ awk -F, 'NR>1{a[$2]+=$3;b[$2]++} END{for(i in a)print i, a[i], b[i]}' Filepear 1 1apple 2 3orange 0 1peach 0 1Taking , as field...
View ArticleAnswer by VenkatC for AWK count number of times a term appear with respect to...
This should work for you? $ cat file.csv 1, apple, 1 2, orange, 0 3, pear, 1 4, apple, 0 5, peach, 0 6, apple, 1$ cat file.csv|awk -F',''{ $3 == 1 && fruit[$2]++; tfruit[$2]++ } END { for ( fr...
View ArticleAWK count number of times a term appear with respect to other columns
Given a CSV file:id, fruit, binary1, apple, 12, orange, 03, pear, 14, apple, 05, peach, 06, apple, 1How can i calculate for each unique values in fruit,the number of times the binary value =1 / number...
View Article