title: Parse a variable row in python
body: <p>Coming from this link: <a href="https://stackoverflow.com/questions/20252728/splitlines-in-python-a-table-with-empty-spaces">Splitlines in Python a table with empty spaces</a></p>
  
  <p>It works well but there is a problem when the size of the columns change:</p>
  
  <pre><code>COMMAND     PID       USER   FD      TYPE DEVICE  SIZE/OFF   NODE NAME
  init          1       root  cwd   unknown                         /proc/1/cwd (readlink: Permission denied)
  init          1       root  rtd   unknown                         /proc/1/root
  </code></pre>
  
  <p>And the problem starts in col Device or Size/OFF but maybe in other situations could happen in all columns.</p>
  
  <pre><code>COMMAND     PID       USER   FD      TYPE             DEVICE  SIZE/OFF       NODE NAME
  init          1       root  cwd       DIR                8,1      4096          2 /
  init          1       root  rtd       DIR                8,1      4096          2 /
  init          1       root  txt       REG                8,1     36992     139325 /sbin/init
  init          1       root  mem       REG                8,1     14696     190970 /lib/libdl-2.11.3.so
  init          1       root  mem       REG                8,1   1437064     190958 /lib/libc-2.11.3.so
  python    30077     carlos    1u      CHR                1,3       0t0        700 /dev/null
  </code></pre>
  
  <p>Checking always is the same in the first row, the first column starts in C of COMMAND, second ends in D of PID, the four col. in D +1 of FD....
  is there any way to count the number of spaces in the first row to use them to fill this code to parse the other rows?</p>
  
  <pre><code># note: variable-length NAME field at the end intentionally omitted
  base_format = '8s 1x 6s 1x 10s 1x 4s 1x 9s 1x 6s 1x 9s 1x 6s 1x'
  base_format_size = struct.calcsize(base_format)
  </code></pre>
  
  <p>Any ideas how to solve the problem?</p>