csv - Count occurence of word using java -


ticket type priority     assigned incident 3 - medium     acknowledgement service request 3 - medium     assigned problem 2 - high     assigned incident 3 - medium     assigned service request 3 - medium     closed incident 3 - medium     assigned service request 3 - medium     assigned incident 2 - high     closed incident 3 - medium     assigned service request 3 - medium     assigned service request 3 - medium     acknowledgement service request 3 - medium     assigned service request 3 - medium     assigned service request 3 - medium     acknowledgement service request 3 - mediumc 

i able above table data webpage using java selenium.
want calculate

  1. no of incident
  2. no of incident + 3 - medium
  3. no of incident + 3 - medium + assigned , on..

and store value csv file specific cell..

i have stored above table date in variable.

public static void get_data()  { string txt = driver.findelement(by.xpath("//*[@class='jtrac jtrac-    list']")).gettext(); system.out.println(txt); } 

i have done earlier above things using powershell this

$b = $a | select-string "incident","problem" | measure-object; $c = $b.count; $obj[0].measure = $c 

$a contains above table data. select-string select pattern string , measure. $obj handles target csv file store data 1 one $obj[*]

but not sure in java.

here below code. matcher object has methods more. change pattern mentioned in method suit need.

 string mytotalstring= "ticket type priority\n" + "    assigned incident 3 - medium\n" + "    acknowledgement service request 3 - medium\n" + "    assigned problem 2 - high\n" + "    assigned incident 3 - medium\n" + "    assigned service request 3 - medium\n" + "    closed incident 3 - medium\n" + "    assigned service request 3 - medium\n" + "    assigned incident 2 - high\n" + "    closed incident 3 - medium\n" + "    assigned service request 3 - medium\n" + "    assigned service request 3 - medium\n" + "    acknowledgement service request 3 - medium\n" + "    assigned service request 3 - medium\n" + "    assigned service request 3 - medium\n" + "    acknowledgement service request 3 - medium";      private int getincidentorproblems()     {         int = 0;         pattern p = pattern.compile("incident|problem");         matcher m = p.matcher( mytotalstring );         while (m.find()) {             i++;         }         return i;     } 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -