title: AttributeError: 'float' object has no attribute 'encode' 3
body: <p>I have the python script for reading a excel to xml format but it was showing some error as</p>
  
  <pre><code>val = sh.row_values(row)[i].encode("utf-8")
  Attribute Error : 'float' object has no attribute 'encode'
  </code></pre>
  
  <p>Here is my code:</p>
  
  <pre><code>import xlrd
  
  wb = xlrd.open_workbook("my_excel_file.xlsx")
  sh = wb.sheet_by_index(0)
  tags = [n.replace(" ", "").lower() for n in sh.row_values(0)]
  
  result = "&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;myItems&gt;\n" 
  
  for row in range(1, sh.nrows): 
      result += "  &lt;item&gt;\n"
      for i in range(len(tags)):    
         tag = tags[i].encode("utf-8")
         val = sh.row_values(row)[i].encode("utf-8")   
         result += "    &lt;%s&gt;%s&lt;/%s&gt;\n" % (tag, val, tag)    
      result += "  &lt;/item&gt;\n"
  
  result += "&lt;/myItems&gt;"   
  
  f = open("myfile.xml", "w")
  f.write(result)
  f.close()
  </code></pre>