title: Python CSV encoding
body: <p>I'm writing a little script that allows me to import my Facebook contacts' email addresses to GMail/Android. My input file has unicode characters, like: Jasmin L\u00f3pez. The generated CSV output file looks like this:</p>
  
  <blockquote>
    <p>Andr\u00e9 Zzz,,,,,,,,,,,,,,,,,,,,,,,,,,fbcontacts ::: * My Contacts,* Home,zzz@yahoo.com<br>
    Andr\u00e9ia Ggg,,,,,,,,,,,,,,,,,,,,,,,,,,fbcontacts ::: * My Contacts,* Home,ggg@hotmail.com<br>Andr\u00e9s Bbb,,,,,,,,,,,,,,,,,,,,,,,,,,fbcontacts ::: * My Contacts,* Home,bbb@gmail.com</p>
  </blockquote>
  
  <p>As you can see I have problems with encodings. I'm creating a Google contacts CSV file but I need names properly displayed. I'm using this function to write the CSV:</p>
  
  <pre><code>def writecsv(self):
      if self.outfile is not '':
          #fh = open(self.outfile, 'wb')
          #fh = codecs.open(self.outfile, "wb", "utf-8")
          fh = codecs.open(self.outfile, 'wb', encoding="latin-1")
      else:
          fh = sys.stdout
  
      csvhdlr = csv.writer(fh, quotechar='"', quoting=csv.QUOTE_MINIMAL)
      csvhdlr.writerow("Name,Given Name,Additional Name,Family Name,Yomi Name,Given Name Yomi,Additional Name Yomi,Family Name Yomi,Name Prefix,Name Suffix,Initials,Nickname,Short Name,Maiden Name,Birthday,Gender,Location,Billing Information,Directory Server,Mileage,Occupation,Hobby,Sensitivity,Priority,Subject,Notes,Group Membership,E-mail 1 - Type,E-mail 1 - Value".split(','))        
      for contact in self.clist:
          #csvhdlr.writerow(dict((vname, vtype, vnotes, vstereotype, vauthor, valias, vgenfile.encode('utf-8')) for vname, vtype, vnotes, vstereotype, vauthor, valias, vgenfile in row.iteritems()))
          row = contact.fullname + ',,,,,,,,,,,,,,,,,,,,,,,,,,fbcontacts ::: * My Contacts,* Home,' + contact.email
          csvhdlr.writerow(row.split(','))
  </code></pre>
  
  <p>Any idea please? I'm quite new to python and everytime I have to use encodings, it doesn't work as I would like to =(</p>
  
  <p>Thanks a lot for your help!</p>