fdutils/html.py
def parse_table_mix_columns(t_labels, t_rows, info_labels, cast_types=(int, str)):
    """ parses the information contained in a table where there can be one header and sub-header
        
        I'm only taking into account one header and one sub-header
        a more general case could be built but that is not my problem at the moment
    """

    cast = lambda v: strings.cast(v, *cast_types)

    labels = [l[0] for l in info_labels]
    sub_labels = [l[1] for l in info_labels] if len(t_labels) > 1 else []

    info = ordered_dict()
    for i, label in enumerate(labels):
        info[label] = ordered_dict()
        for sub_label in sub_labels[i]:
            info[label][sub_label] = ordered_dict()

    t_labels = t_labels[1]

    on_header_section = True

    for i, row in enumerate(t_rows):
        title = row.pop(0)

        if i == t_labels[1]:
            on_header_section = False

        sub_label_count = 0

        for label_index, label in enumerate(labels):

            if on_header_section:
                info[label][title] = cast(row[label_index])

            elif sub_labels:
                for sl, sub_label in enumerate(sub_labels[label_index]):
                    info[label][sub_label][title] = cast(row[sub_label_count])
                    sub_label_count += 1

    return info
 parses the information contained in a table where there can be one header and sub-header
        
        I'm only taking into account one header and one sub-header
        a more general case could be built but that is not my problem at the moment
    
parses the information contained in a table where there can be one header and sub-header
I'm only taking into account one header and one sub-header
a more general case could be built but that is not my problem at the moment
parses the information contained in a table where there can be one header and sub - header I ' m only taking into account one header and one sub - header a more general case could be built but that is not my problem at the moment
def parse_table_mix_columns(t_labels, t_rows, info_labels, cast_types=(int, str)):
    cast = lambda v: strings.cast(v, *cast_types)
    labels = [l[0] for l in info_labels]
    sub_labels = [l[1] for l in info_labels] if len(t_labels) > 1 else []
    info = ordered_dict()
    for i, label in enumerate(labels):
        info[label] = ordered_dict()
        for sub_label in sub_labels[i]:
            info[label][sub_label] = ordered_dict()
    t_labels = t_labels[1]
    on_header_section = True
    for i, row in enumerate(t_rows):
        title = row.pop(0)
        if i == t_labels[1]:
            on_header_section = False
        sub_label_count = 0
        for label_index, label in enumerate(labels):
            if on_header_section:
                info[label][title] = cast(row[label_index])
            elif sub_labels:
                for sl, sub_label in enumerate(sub_labels[label_index]):
                    info[label][sub_label][title] = cast(row[sub_label_count])
                    sub_label_count += 1
    return info
def parse_table_mix_columns ( t_labels , t_rows , info_labels , cast_types = ( int , str ) ) : cast = lambda v : strings . cast ( v , * cast_types ) labels = [ l [ 0 ] for l in info_labels ] sub_labels = [ l [ 1 ] for l in info_labels ] if len ( t_labels ) > 1 else [ ] info = ordered_dict ( ) for i , label in enumerate ( labels ) : info [ label ] = ordered_dict ( ) for sub_label in sub_labels [ i ] : info [ label ] [ sub_label ] = ordered_dict ( ) t_labels = t_labels [ 1 ] on_header_section = True for i , row in enumerate ( t_rows ) : title = row . pop ( 0 ) if i == t_labels [ 1 ] : on_header_section = False sub_label_count = 0 for label_index , label in enumerate ( labels ) : if on_header_section : info [ label ] [ title ] = cast ( row [ label_index ] ) elif sub_labels : for sl , sub_label in enumerate ( sub_labels [ label_index ] ) : info [ label ] [ sub_label ] [ title ] = cast ( row [ sub_label_count ] ) sub_label_count += 1 return info
parses the information contained in a table where there can be one header and sub-header
I'm only taking into account one header and one sub-header
a more general case could be built but that is not my problem at the moment
parses the information contained in a table where there can be one header and sub - header I ' m only taking into account one header and one sub - header a more general case could be built but that is not my problem at the moment
""" parses the information contained in a table where there can be one header and sub-header
        
        I'm only taking into account one header and one sub-header
        a more general case could be built but that is not my problem at the moment
    """
t_labels
t_rows
info_labels
cast_types