Quantcast
Channel: AWK count number of times a term appear with respect to other columns - Stack Overflow
Browsing latest articles
Browse All 3 View Live

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 Article



Answer 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 Article

AWK 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
Browsing latest articles
Browse All 3 View Live


Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>