title: Add new column along with previous columns in csv in java (duplicate)
body: <p>I have an arraylist which would be different in size with different times . I want to store it as separate column in a csv along with previous columns. I tried <a href="https://stackoverflow.com/questions/34590971/java-append-new-column-to-csv-file">this solution</a> but It's  actually not working. But in the second solution It adds all value in a row what actually I don't want.
  Possible duplication would be <a href="https://stackoverflow.com/questions/40540797/how-to-print-two-arraylists-to-a-csv-file-with-multiple-columns">this</a>.</p>
  
  <pre><code>public class writeLine {
      public static void generateCSV(PrintWriter pw, ArrayList&lt;Double&gt; list,int n) throws IOException{
          for(int i= 0; i &lt; list.size(); i++) {
              pw.print(String.format("%f%n", list.get(i)));
          }
          pw.flush();
      }
  }
  </code></pre>
  
  <p>Here is my code which add values in the same column. But I want each time as a new column along with previous column. What should I modify in this code?</p>
  
  <p>I also tried first to read my csv then I add new arraylist values. But the problem is when my arraylist size in greater than the csv rows it will not add the rest of values of the arraylist. </p>