title: numpy recarray strings of variable length
body: <p>Is it possible to initialise a numpy recarray that will hold strings, without knowing the length of the strings beforehand?</p>
  
  <p>As a (contrived) example:</p>
  
  <pre><code>mydf = np.empty( (numrows,), dtype=[ ('file_name','STRING'), ('file_size_MB',float) ] )
  </code></pre>
  
  <p>The problem is that I'm constructing my recarray in advance of populating it with information, and I don't necessarily know the maximum length of <code>file_name</code> in advance.</p>
  
  <p>All my attempts result in the string field being truncated:</p>
  
  <pre><code>&gt;&gt;&gt; mydf = np.empty( (2,), dtype=[('file_name',str),('file_size_mb',float)] )
  &gt;&gt;&gt; mydf['file_name'][0]='foobarasdf.tif'
  &gt;&gt;&gt; mydf['file_name'][1]='arghtidlsarbda.jpg'
  &gt;&gt;&gt; mydf
  array([('', 6.9164002347457e-310), ('', 9.9413127e-317)], 
        dtype=[('file_name', 'S'), ('file_size_mb', '&lt;f8')])
  &gt;&gt;&gt; mydf['file_name']
  array(['f', 'a'], 
        dtype='|S1')
  </code></pre>
  
  <p>(As an aside, why does <code>mydf['file_name']</code> show 'f' and 'a' whilst <code>mydf</code> shows '' and ''?)</p>
  
  <p>Similarly, if I initialise with type (say) <code>|S10</code> for <code>file_name</code> then things get truncated at length 10.</p>
  
  <p>The only similar question I could find is <a href="https://stackoverflow.com/questions/1664917/automatic-string-length-in-recarray">this one</a>, but this calculates the appropriate string length <em>a priori</em> and hence is not quite the same as mine (as I know nothing in advance).</p>
  
  <p>Is there any alternative other than initalising the <code>file_name</code> with (eg) <code>|S9999999999999</code> (ie some ridiculous upper limit)?</p>