title: Python : XLRD; compare the columns length
body: <p>I'm using <code>xlrd</code> to work on xls files. My xls file has got two columns and my requirement is to make sure both the columns have got equal number of rows. I learnt from <code>help()</code> that we have got a <code>row_len()</code> to look for the length of a row given with the index, but unable to find any for <code>col_len</code>. Can you please help with any</p>
  
  <p>Here is my code</p>
  
  <pre><code>from xlrd import open_workbook
  spread_sheet=open_workbook("simple.xls")
  sheet1=spread_sheet.sheet_by_index(0)
  
  #validates the no of columns in the Spread sheet
   if sheet1.ncols == 2:
    for sheet1_rows in range(sheet1.nrows):
      for sheet1_cols in range(sheet1.ncols):
          value=sheet1.cell(sheet1_rows,sheet1_cols).value
          source=sheet1.cell(sheet1_rows,0).value
          destination=sheet1.cell(sheet1_rows,1).value
      #ignores the Source and Destination Headers 
      if value not in ('Source','Destination'):
          print "Source is : %s \nDestination is : %s\n" %    (source,destination)
   else:
    print "XLS provided is not valid. Check the no of columns is 2"
  </code></pre>
  
  <p>Some other options apart from comparing the below please</p>
  
  <pre><code>&gt;&gt;&gt; print len(sheet1.col_values(0))
  8
  &gt;&gt;&gt; print len(sheet1.col_values(1))
  8
  </code></pre>
  
  <hr>
  
  <p>Thanks for your reply @alecxe. Instead adding few more lines to my code, I found out something below. please advise will this work out</p>
  
  <pre><code> &gt;&gt;&gt; print len(sheet1.col_values(0))
   6
   &gt;&gt;&gt; print len(sheet1.col_values(1))
   6
   &gt;&gt;&gt; sheet1.col_values(0)
   [u'A', 1.0, 1.0, 1.0, 1.0, 2.0]
   &gt;&gt;&gt; sheet1.col_values(1)
   [u'B', 2.0, 2.0, 2.0, 2.0, '']
   &gt;&gt;&gt; print len(filter(None,sheet1.col_values(1)))
   5
   &gt;&gt;&gt;
  </code></pre>