title: convert xls to json in python
body: <p>I am trying to convert xls to json and but when I am executing the code it's not giving me the data inside xls sheet, it's only giving me the json structure.
  Below is the code which I am running, I am not able to understand what modification I should further make in this so that I can get a perfect json file.</p>
  
  <p>Please note - input is in the form of binary stream and output is also in the form of a stream and not file.</p>
  
  <pre><code>    #!/usr/bin/python -u
  import sys
  import xlrd
  import simplejson
  from collections import OrderedDict
  
  wb = xlrd.open_workbook(file_contents=sys.stdin.read())
  
  for sheet_index in range(wb.nsheets):
  #       print sheet_index
          sh =  wb.sheet_by_index(sheet_index)
         # print "Processing sheet no ", sheet_index
          attributes = sh.row_values(0)
          #print attributes
          rows_list = []
          attr_list = []
         # print attr_list[0]
  
          for rownum in range(1,sh.nrows):
                  row_val_list = sh.row_values(rownum)
                  row_dict = OrderedDict()
                  for index in range(len(attr_list)):
                          row_dict[attr_list[index]] = row_val_list[index]
  
                  #row_dict['ID'] = row_val_list[0]
                  #row_dict['Name'] = row_val_list[1]
  
                  #rows_list.append(row_dict)
  
          #json_data = simplejson.dumps(rows_list)
          #sys.stdout.write(json_data)
                  rows_list.append(row_dict)
                  json_data = simplejson.dumps(rows_list)
                  sys.stdout.write(json_data)
  
  #       json_data = simplejson.dumps(rows_list)
  
          #sys.stdout.write(json_data)
  ~
  </code></pre>
  
  <p>Any help is much appreciated</p>