How to get count of specific keyword from CSV file uipath


#1

He Guys,

I have written a log file for status, there is a pass and fail status in the CSV file, need to write the count for pass or fail status.


#2

Hi @smita.mobifly,

  1. Read the CSV to a datatable using ‘Read CSV’ activity.
  2. Use ‘Output Datatable’ activity to convert the datatable into string.
  3. Assign int_count= System.Text.RegularExpressions.Regex.Matches(your_string,"Pass").Count
    It shows the number of occurrence of the keyword “Pass” and you can do same to the string “Fail” also.

Warm regards,
Nimin


#3

Hi @smita.mobifly,

The above method displays all the occurrence of the string Pass/Fail in your CSV. If any other columns contains “Pass,Fail”, it also counts that too. If you want to get “Pass/Fail” count in a particular column, you can use this.
Assign int_PassCount = DT1.Select("YourColumnName ='Pass'").CopyToDataTable.Rows.Count
and int_FailCount = DT1.Select("YourColumnName ='Fail'").CopyToDataTable.Rows.Count

Warm regards,
Nimin


#4

Thanks, solved.


closed #5

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.