Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have a file with hundreds of rows and about 60 columns looks like this
I want to count the number of Yes and No that exist in A PARTICULAR ROW.
id|A|B|C|.....
1|yes|yes|no|.....
2|no|yes|no|....
.
.
.
i want an output like this
id|numOfYes|numOfNo
1|2|1
2|1|2
.
.
.
how can i achieve that?
Thanks
Hi,
You can use this pattern
1. Read each entire rows of your file,
2. In tmap split your id row and count the number of 'yes' and 'no'
out1.id = new Integer(row2.line.substring(0, row2.line.indexOf("|", 1)) ) // id
out1.numYes = StringHandling.COUNT(StringHandling.UPCASE(row2.line), "YES") // number of yes
out1.numNo = StringHandling.COUNT(StringHandling.UPCASE(row2.line), "NO") // number of no
3. write your data using tfileoutputdelimited component