title: How to read multiple csv files dynamically with jmeter
body: <p>I'm trying to read multiple csv files from a specific folder using Jmeter</p>
  
  <p>Until now I read one csv file and I could loop it with a thread that runned X times when X- is the number of lines in the file.
  I was counting the number of lines in the csv file before the thread with a bean_shell like that:</p>
  
  <pre><code>    import org.apache.jmeter.services.FileServer;
  String DirPath = FileServer.getFileServer().getBaseDir();
  FileReader fileReader = new FileReader(new File(DirPath + "/files/App1.csv"));
  LineNumberReader lineReader = new LineNumberReader(fileReader);
  int linenumber = 0;
  while (lineReader.readLine() != null){
  linenumber++;
  }
  props.put("rowsnumberApp", Integer.toString(linenumber));
  </code></pre>
  
  <p>Now, I want to read multiple files from a folder, when the amount of files in the folder can dynamically change, </p>
  
  <p>The files names will be like that:</p>
  
  <p>app1</p>
  
  <p>app2</p>
  
  <p>app3</p>
  
  <p>app...</p>
  
  <p>I have this code to read all files from the folder:</p>
  
  <pre><code>import org.apache.jmeter.services.FileServer;
  String DirPath = FileServer.getFileServer().getBaseDir();
  File folder = new File(DirPath + "/files");
  File[] files = folder.listFiles();
  int counter = 1;
  for (File file : files) {
      vars.put("file_" + counter, file.getAbsolutePath());
      counter++;
  }
  </code></pre>
  
  <p>Each file has different amount of lines (but at least I have the same soap-request for all of them)</p>
  
  <p>I realized that using a loop controller on csv gives only the first line.</p>
  
  <p>And as you can see I already have the code part for reading files from a folder and counting the number of lines,</p>
  
  <p>I just need a way to connect all of this to be able to loop for all csv files in the folder</p>
  
  <p>so any idea?</p>