import re


def seperate_data(data, labels):
    """
    Given a data file such as

        | x11 u11 x12 other x13 |
        | x21 u21 x22 other x23 |
        | ..................... |

    And labels for each column such as

          'x' 'u' 'x' '_'   'x'

    Split the data into x' and u'

    """

    # Take the index of all instances of 'x', get the cols with
    # that index, which should be the states.
    xt = data[:, [m.start() for m in re.finditer('x', labels)]]
    # Save as above, but with 'u' and inputs.
    ut = data[:, [m.start() for m in re.finditer('u', labels)]]
    return xt, ut