title: Reading large formatted text file with NumPy
body: <p>I've volunteered to help someone convert a finite element mesh from one format to another (i-deas *.unv to Alberta). I've used NumPy to do some additional shaping of the mesh, but I'm having problems reading the raw text file data into NumPy arrays. I've tried genfromtxt and loadtxt with no success so far.</p>
  
  <p>Some details: </p>
  
  <p>1) All groups are delimited by the header and footer flag "    -1" on its own line.</p>
  
  <p>2) The NODE group has a header "  2411" on its own line. I only want to read alternate lines from this group, skipping each line with 4 integers, but reading the line with 3 Fortran double precision numbers.</p>
  
  <p>3) The ELEMENT connectivity group has a header "  2412" on its own line. All data are integers and only the first 4 columns are required to be read. There will be some empty slots in the NumPy array due to missing values for 2 and 3 node elements.</p>
  
  <p>4) The " 2477" node groups I think I can deal with myself using regular expressions that find which lines to read.</p>
  
  <p>5) The real data file will have about 1 million lines of text, so I'm very keen for it to be vectorized if possible (or whatever NumPy does to read stuff quickly).</p>
  
  <p>Sorry if I've given too much information, and thanks.</p>
  
  <p>The lines below are a sample of parts of the *.unv text file format. </p>
  
  <pre><code>    -1
    2411
    146303         1         1        11
    6.9849462399269246D-001  8.0008842847097805D-002  6.6360238055630028D-001
    146304         1         1        11
    4.1854795755893875D-001  9.1256034628308313D-001  3.5725496189239300D-002
    146305         1         1        11
    7.5541258490349616D-001  3.7870257739063029D-001  2.0504544370783115D-001
    146306         1         1        11
    2.7637569971086767D-001  9.2829777518336010D-001  1.3757239038663285D-001
     -1
     -1
   2412
       9        21         1         0         7         2
       0         0         0
       1         9
      10        21         1         0         7         2
       0         0         0
       9        10
    1550        91         6         0         7         3
     761      3685      2027
    1551        91         6         0         7         3
     761      2380      2067
   39720       111         1         0         7         4
   71854     59536     40323     73014
   39721       111         1         0         7         4
   45520     48908    133818    145014
     -1
     -1
     2477
       1         0         0         0         0         0         0      3022
  PERMANENT GROUP1
       7         2         0         0         7         3         0         0
       7         8         0         0         7         7         0         0
       7       147         0         0         7       148         0         0
       2         0         0         0         0         0         0      2915
  PERMANENT GROUP2
       7         1         0         0         7         5         0         0
       7         4         0         0         7         6         0         0
       7         9         0         0         7        11         0         0
     -1
  </code></pre>