title: Python flask writing to a csv file and reading it
body: <p>I can read from the CSV file but I'm unsure as to how I can write to it. </p>
  
  <p>The idea is to have allow the user to enter their comment and it save on the CSV file and then further print out the comment</p>
  
  <p>This is the code for reading for reading the csv file</p>
  
  <pre><code>from flask import Flask, render_template
  from flask import request
  import csv
  
  def comments():
      with open('static\\comments.csv', 'r') as inFile: 
          reader = csv.reader(inFile)
          commentsList = [row for row in reader]
  </code></pre>
  
  <p>Here is the code that I am using to display the fields within the csv file. I want to use the form to somehow add fields to the given csv file</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;table border="1"&gt;
      {% for line in commentsList %}
      &lt;tr&gt;
      {% for item in line%}
      &lt;td&gt;
      {{item}}
      &lt;/td&gt;
      {% endfor %}
      &lt;/tr&gt;
      {% endfor %}
      &lt;/table&gt;
      &lt;/div&gt;
      &lt;form action="addToComments" method="post"&gt;
      Name: &lt;input type="text" name="username"&gt;
      Comment: &lt;input type="text" name="comment"&gt;
      Date: &lt;input type="date" name="date"&gt;
      &lt;input type="submit" value="Submit"&gt;
      &lt;/form&gt; 
  </code></pre>