title: Which encoding to use while reading Excel using xlrd
body: <p>I am trying to read an Excel file using xlrd to write into txt files. Everything is being written fine except for some rows which has some spanish characters like 'Téd'. I can encode those using latin-1 encoding. However the code then fails for other rows which have a 'â' with unicode u'\u2013'. u'\2013' can't be encoded using latin-1. When using UTF-8 'â' are written out fine but 'Téd' is written as 'TÃ©d' which is not acceptable. How do I correct this.</p>
  
  <p>Code below :</p>
  
  <pre><code>#!/usr/bin/python
  import xlrd
  import csv
  import sys
  
  filePath     = sys.argv[1]
  
  with xlrd.open_workbook(filePath) as wb:
       shNames = wb.sheet_names()
       for shName in shNames:
           sh = wb.sheet_by_name(shName)
           csvFile = shName + ".csv"
           with open(csvFile, 'wb') as f:
                c = csv.writer(f)
                for row in range(sh.nrows):
                    sh_row = []
                    cell = ''
                    for item in sh.row_values(row):
                        if isinstance(item, float):
                           cell=item
                        else:
                           cell=item.encode('utf-8')
                        sh_row.append(cell)
                        cell=''
                    c.writerow(sh_row)
           print shName + ".csv File Created"
  </code></pre>