Shankar Cheerala
Shankar Cheerala

Reputation: 2007

In Jmeter bean shell preprocess is there any way to read the lines of CSV data file and put into an array

In Jmeter bean shell preprocess is there any way to read the lines of CSV data file and put into an array csv file contains data1 date2 date2 i want put all three values in to array and send to Http request in jmeter for for each controller

Thanks in Advance

Upvotes: 1

Views: 9862

Answers (1)

Dmitri T
Dmitri T

Reputation: 168002

If you want the Beanshell

BufferedReader reader = new BufferedReader(new FileReader("path.to.your.file.csv"));
int counter = 1;        

for(String line; (line = reader.readLine()) != null; ) {
    vars.put("date" + counter, line);
    counter++;
}  

However I don't see any value added by Beanshell here, it is recommended to avoid scripting and use JMeter components where possible. If you need to send values from CSV file consecutively I would recommend using one of the following test elements instead:

Upvotes: 4

Related Questions