'Decode the shape of the given text'

def _shape_text(self, text, colsep=u' DCTB ', rowsep=u'\n', transpose=False, skiprows=0, comments='#'):

    assert (colsep != rowsep)
    out = []
    text_rows = text.split(rowsep)[skiprows:]
    for row in text_rows:
        stripped = to_text_string(row).strip()
        if ((len(stripped) == 0) or stripped.startswith(comments)):
            continue
        line = to_text_string(row).split(colsep)
        line = [try_to_parse(to_text_string(x)) for x in line]
        out.append(line)
    if programs.is_module_installed('numpy'):
        from numpy import nan
        out = list(zip_longest(fillvalue=nan, *out))
    else:
        out = list(zip_longest(fillvalue=None, *out))
    out = [[r[col] for r in out] for col in range(len(out[0]))]
    if transpose:
        return [[r[col] for r in out] for col in range(len(out[0]))]
    return out
