def mmcif_lines_to_mmcif_blocks(lines):
    """A .cif file is ultimately a list of tables. This function takes a list of
    .cif file lines and splits them into these table blocks. Each block will be
    a ``dict`` containing a category name and a list of lines.

    :param deque lines: the .cif file lines.
    :rtype: ``list``"""
    category = None
    block, blocks = [], []
    while lines:
        line = lines.popleft()
        if line.startswith('data_'):
            continue
        if line.startswith('_'):
            line_category = line.split('.')[0]
            if line_category != category:
                if category:
                    blocks.append({'category': category[1:], 'lines': block})
                category = line_category
                block = []
        if line.startswith('loop_'):
            if category:
                blocks.append({'category': category[1:], 'lines': block})
            category = lines[0].split('.')[0]
            block = []
        block.append(line)
    if block:
        blocks.append({'category': category[1:], 'lines': block})
    return blocks
