title: How to convert List of Maps to CSV
body: <p>I need to convert List of Maps to CSV object which should like below </p>
  
  <pre><code>List&lt;Map&lt;String,Object&gt;&gt; maps = new ArrayList&lt;Map&lt;String,Object&gt;&gt;();
  </code></pre>
  
  <p>maps object contains the value in below format</p>
  
  <p>map 1 :</p>
  
  <pre><code>(header 1, value1)
  
  (header 2, value2)
  
  (header 3, value3)
  
  (header 4, value4)
  </code></pre>
  
  <p>map 2 : </p>
  
  <pre><code>(header 1, value5)
  
  (header 2, value6)
  
  (header 3, value7)
  
  (header 4, value8)
  </code></pre>
  
  <p>I am looking for CSV which should like below </p>
  
  <pre><code>header1, header2,header3, header4
  
  value1, value2,value3,value4
  
  value5,value6,value7,value8
  </code></pre>
  
  <p>I have tried to read the map (key, value) and writing to CSV files, but its writing to the format </p>
  
  <p>header 1, value1 </p>
  
  <p>header2, value2 </p>
  
  <p>header 3,value3 </p>
  
  <p>header4,value4 </p>
  
  <p>header1,value5 </p>
  
  <p>like this below is the code snippet which I have tried for </p>
  
  <pre><code>(Map&lt;String, Object&gt; map : maps) {
  
   for (Map.Entry&lt;String, Object&gt; entry : map.entrySet()) {
  
  w.append(entry.getKey()).append(",").append(entry.getValue()‌​.toString()).append(‌​"\n"); } } 
  </code></pre>