Search code examples
javascriptjmeterperformance-testing

How to fetch the number/count of number of rows having data in excel for the jmeter


How to fetch the number/count of the number of rows having data in excel for the jmeter?

Description:

  1. I would like to count the number of rows having data in the excel and give that count to the "number of threads" field in jmeter
  2. The Excel/CSV is configured in the jmeter "csv configuration" method.
  3. When I run I want the jmeter to first calculate the number of rows from the csv and insert in the "Number of threads" field in jmeter

Could someone please help me on this.Your help will be much appreciated.

Thanks & Regards

Paul Baboo


Solution

  • You can get number of lines in file using __groovy() function like:

    ${__groovy(new File('test.csv').readLines().size(),)}
    

    The function can be placed directly into Number of Threads (users) section of the Thread Group