Jmeter: Using CSV file with uneven columns to test drive sampler

Viewed 75

I have a csv file that has a list of stores. For every Store there are 10 departments. I will need to make a GET API call for all the 10 departments in 100 stores. So my columns in CSV file are not eve. I will have column A with 100 store IDs, and column B with 10 department IDs. How can I use every Store ID 10 times (once with every department ID) in Jmeter sampler?

1 Answers

If you want to achieve this using CSV Data Set Config - the only way is splitting your CSV file into 2 separate files

If the CSV file comes from external source and cannot be changed - you can consider using __groovy() function like:

${__groovy(new File('test.csv').readLines().get(vars.get('__jm__Loop Controller - Store__idx') as int).split('\,')[0],)}

Given example CSV file test.csv with the following contents:

store1,department1
store2,department2
,department3
,department4
,department5
,department6
,department7
,department8
,department9
,department10

You can achieve your requirement using below approach:

enter image description here

More information on Groovy scripting in JMeter: Apache Groovy - Why and How You Should Use It

Related