title: Write data to CSV file with column name using python
body: <p>I m using the below python code to write data to a CSV file with column name.</p>
  <pre class="lang-py prettyprint-override"><code>def get_filename_datetime():
      # Use current date to get a text file name.
      return &quot;Report-&quot; + str(datetime.date.today())
  # Get full path for writing.
  filename = get_filename_datetime()
  Data = [[&quot;FirstName&quot;, &quot;LastName&quot;,&quot;Failed_User_Id&quot;],
            [firstname, lastname, faileduserid]]
  Reportfilename = os.path.join(reportspath, filename)
  myfile = open(Reportfilename + '-Results.csv', &quot;a+&quot;)
  with myfile:
      writer = csv.writer(myfile)
      writer.writerows(Data)
  </code></pre>
  <p>I'm getting output in a file as:</p>
  <p><a href="https://i.stack.imgur.com/7PoKh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7PoKh.png" alt="actual output" /></a></p>
  <p>My expected output is:</p>
  <p>I'm getting output in a file as:</p>
  <p><a href="https://i.stack.imgur.com/ac5YD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ac5YD.png" alt="expected output" /></a></p>
  <p>But I'm getting column name printed for each and every row.</p>