title: Writing and reading the most recent(by date) rows from database
body: <p>I have three questions on the below code ,basically I am trying to write rows with format currentdate ,count,keep appending the row date to teh same .csv file..read the recent most 5 entries and print it,currently I tried the below and running into following error.</p>
  
  <p>1.How do I write a row  with format current date,count to a csv file
  2.how to keep appending the same .csv file next time the script is run
  3.how to get the recent(by date) 5 entries from .csv file </p>
  
  <pre><code>import csv
  import datetime
  
  icount=5
  now = datetime.datetime.now()
  time =now.strftime("%Y-%m-%d %H:%M")
  #Keep appending date and count everytime this script is run
  c = csv.writer(open("trend.csv", "wb"))
  c.writerow(time,icount)
  
  #Now read the recent 5 entries and print
  cr = csv.reader(open("trend.csv","rb"))
  
  for row in cr:    
      print row
  </code></pre>
  
  <p>Error:-</p>
  
  <pre><code>&gt;&gt;&gt;&gt;python database.py
  Traceback (most recent call last):
    File "database.py", line 9, in &lt;module&gt;
      c.writerow(time,icount)
  TypeError: writerow() takes exactly one argument (2 given)
  </code></pre>