title: Proper way to save Jmeter Results to csv - how to finalize results file
body: <p>I do the same scenario that was already described in other topics not at once: I'm trying to save Jmeter results to database from csv file. </p>
  
  <p>I have an Aggregate Report listener that saves results to csv file, and everything is OK here. 
  I also added TearDown Thread Group to my scenario that gets strings from this csv file (by CSV DataSet config) and processes it to database. This part also works fine with static CSV.</p>
  
  <p>Two problems here: </p>
  
  <ol>
  <li>Aggregate Report listener is added on the top level of scenario. So, it adds all samplers from TearDown group to results file as well. So, it's like a recursion: if I do teardown until end of result file, I'll never reach the end, as every new iteration adds some new rows.</li>
  <li>At the moment when CSV dataset config takes csv file, it's still in memory only and not finalized to disk. So, file is just empty. How to tell Jmeter that it should write the content from memory to a file and close input stream?</li>
  </ol>
  
  <p>Any ideas how to solve it?</p>
  
  <p>I know that I can move Listener into threads, but in this case I have to duplicate it for every thread group. It's always better to have one listener in one place as I can potentially change its settings.</p>
  
  <p>Thanks in advance.</p>