title: How do I create a csv file with dynamically rows
body: <p>I just can't figure out how to create a csv file with dynamically rows. 
  I used commons-csv to write 3 rows to a file but I need some more.</p>
  
  <p>I'm reading values out of a database line by line which look like that:</p>
  
  <pre><code>[ID:1,TSP:'2018-01-01 00:10:00', VALUE: 856830, VAL1:'36,704'],
  [ID:4,TSP:'2018-01-01 00:12:00', VALUE: 736830, VAL1:'1,14'],
  [ID:5,TSP:'2018-01-01 00:10:00', VALUE: 656830, VAL1:'12,504'],
  [ID:5,TSP:'2018-01-01 00:50:00', VALUE: 936830, VAL1:'5,18'],
  [ID:3,TSP:'2018-01-01 00:10:00', VALUE: 736860, VAL1:'3,4'],
  [ID:4,TSP:'2018-01-01 00:50:00', VALUE: 726830, VAL1:'9,14']
  </code></pre>
  
  <p>I wanna create a .csv file with a formatting like that:</p>
  
  <pre><code>TSP(2018-01-01 00:10:00) | VALUE_ID1 | VAL_ID1 | VALUE_ID3 | VAL_ID3 | VALUE_ID5 | VAL_ID5
  
  TSP(2018-01-01 00:12:00) | VALUE_ID4 | VAL_ID4
  
  TSP(2018-01-01 00:50:00) | VALUE_ID4 | VAL_ID4 | VALUE_ID5 | VAL_ID5
  </code></pre>
  
  <p>I hope anyone can help me out with this one, cuz it kills me...</p>
  
  <p>Thanks in advance!</p>
  
  <p>EDIT:</p>
  
  <p>I used groupBy on the TSP so I have the following pattern now: </p>
  
  <pre><code>TSP(2018-01-01 00:10:00):[[ID:1,TSP(2018-01-01 00:10:00),VALUE_ID1,VAL_ID1], [ID:3,TSP(2018-01-01 00:10:00),VALUE_ID3,VAL_ID3], [ID:5,TSP(2018-01-01 00:10:00),VALUE_ID5,VAL_ID5]]
  
  TSP(2018-01-01 00:12:00):[[ID:4,TSP(2018-01-01 00:10:00),VALUE_ID4,VAL_ID4]]
  </code></pre>
  
  <p>etc. that's where I got stuck now –</p>