admin管理员组

文章数量:1418715

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

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

Share Improve this question edited Apr 20, 2018 at 7:26 Gaurav joshi 1,7991 gold badge15 silver badges28 bronze badges asked Apr 20, 2018 at 6:14 paul baboopaul baboo 1191 gold badge5 silver badges14 bronze badges 5
  • Did you mean Java? – CertainPerformance Commented Apr 20, 2018 at 6:15
  • yes my requirement is in java,which can used to read the total number of validrows with data from the csv file – paul baboo Commented Apr 20, 2018 at 9:05
  • Java is to Javascript as Pain is to Painting, or as Car is to Carpet – CertainPerformance Commented Apr 20, 2018 at 9:06
  • Does Anyone know how to do this.if so please help me on this – paul baboo Commented Apr 20, 2018 at 10:23
  • 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 Commented Apr 20, 2018 at 16:46
Add a ment  | 

2 Answers 2

Reset to default 4

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

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.

  1. Fetch the count in another thread group

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

Hope this is what you are looking for.

本文标签: javascriptHow to fetch the numbercount of number of rows having data in excel for the jmeterStack Overflow