title: Adding data to a CSV file through Python
body: <p>I've got a function that adds new data to a csv file. I've got it somewhat working. However, I'm having a few problems.</p>
  
  <ol>
  <li>When I add the new values <code>(name, phone, address, birthday)</code>, it adds them all in one column, rather than separate columns in the same row. (Not really much idea on how to split them up in various columns...)</li>
  <li>I can only add numbers rather than string values. So if I write <code>add_friend(blah, 31, 12, 45)</code>, it will come back saying <code>blah</code> is not defined. However, if I write <code>add_friend(3,4,5,6)</code>, it'll add that to the new row—but, into a single column</li>
  <li>An objective with the function is: If you try and add a friend that's already in the csv (say, Bob), and his address, phone, birthday are already in the csv, if you <code>add_friend(Bob, address, phone, birthday)</code>, it should state <code>False</code>, and not add it. However, I have no clue how to do this. Any ideas?</li>
  </ol>
  
  <p>Here is my code: </p>
  
  <pre><code>def add_friend (name, phone, address, birthday):
      with open('friends.csv', 'ab') as f:
         newrow = [name, phone, address, birthday]
         friendwriter = csv.writer(open('friends.csv', 'ab'), delimiter=' ',
                                     quotechar='|', quoting=csv.QUOTE_MINIMAL)
        friendwriter.writerow(newrow)
        #friendreader = csv.reader(open('friends.csv', 'rb'), delimiter=' ', quotechar='|')
        #for row in friendreader:
          #print ' '.join(row)
  
       print newrow
  </code></pre>