title: How detect length of a numpy array with only one element?
body: <p>I am reading in a file using numpy.genfromtxt which brings in columns of both strings and numeric values.  One thing I need to do is detect the length of the input. This is all fine provided there are more than one value read into each array. </p>
  
  <p>But...if there is only one element in the resulting array, the logic fails.  I can recreate an example here:</p>
  
  <pre><code>import numpy as np
  a = np.array(2.3)
  </code></pre>
  
  <p>len(a) returns an error saying:</p>
  
  <pre><code>TypeError: len() of unsized object
  </code></pre>
  
  <p>however, If a has 2 or more elements, len() behaves as one would expect.</p>
  
  <pre><code>import numpy as np
  a = np.array([2.3,3.6])
  </code></pre>
  
  <p>len(a) returns 2</p>
  
  <p>My concern here is, if I use some strange exception handling, I can't distinguish between a being empty and a having length = 1.</p>
  
  <p>EDIT:
  @noskio suggested setting a = np.array([2.3]).  The problem is, the actual genesis of a is by using numpy.genfromtxt.  The code looks like this:</p>
  
  <pre><code>import numpy as np
  indata = np.genfromtxt(some_filename, names=True,dtype=None)
  a = indata['one_col_headername']
  </code></pre>
  
  <p>As a result, if indata is only one row in the file, a is a 0-d array.</p>