I want My Jmeter to read multiple csv file from a location say c:\Jmeter\file.
Currently if i provide the specific csv file name in'Filename' under CSV data Set Config, the Jmeter recognizes the file ans execute my script.
I don't want to hard code the file name , i want the jmeter to read automatically from the location.
I have written BeenShell PreProcessor (since i couldn't find any simple solution) this program reads the list all csv files from location and stores them in variable. 'VcsvFilename'
import java.io.File;
File folder = new File("C:\\Intel\\CsvFiles");
File[] listOfFiles = folder.listFiles();
String[] desiredNamesOfListOfFiles = new String[listOfFiles.length];
String strFileName;
int intCounter=0;
String count;
int idx = 0 ;
for (int i = 0; i < listOfFiles.length; i++) {
File file = listOfFiles[i];
if (file.isFile() && file.getName().endsWith(".csv")) {
/* do somthing with content */
System.out.println(" File Name is ~~~~~~~~~~~~~~~~~~ " + file.getName());
desiredNamesOfListOfFiles[idx++] = file.getName();
}
}
System.out.println(" Length of array is " + desiredNamesOfListOfFiles.length);
for(int j = 0 ; j < idx ; j++){
// System.out.println(" File name inside array is " + desiredNamesOfListOfFiles[j]);
// ;;vars.put("VcsvFilename",desiredNamesOfListOfFiles[j]);
strFileName = strFileName + ";" +desiredNamesOfListOfFiles[j];
intCounter++;
}
count=Integer.toString(intCounter);
vars.put("VcsvFilename",strFileName);
vars.put("FileCounter",count);
I am not able to use this variable under CSV data config.
Does some one has any solution for it?