0
votes

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

2
Did you mean Java?CertainPerformance
yes my requirement is in java,which can used to read the total number of validrows with data from the csv filepaul baboo
Java is to Javascript as Pain is to Painting, or as Car is to CarpetCertainPerformance
Does Anyone know how to do this.if so please help me on thispaul baboo
so you want to set the thread-count from the no. of lines present in the csv? FYI- Excel is not supported by JMeter out of the box.Amol Chavan

2 Answers

3
votes

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

2
votes

Please check the below plan:-

  1. First "Thread group" is going to read csv and give the count. Used beanshell preprocessor. You can use groovy if you like for performance matters.

enter image description here

  1. Fetch the count in another thread group

enter image description here

Below you can see based on the rows in CSV, 4 number of thread executed with 1 loop.

enter image description here

Hope this is what you are looking for.