#!/usr/bin/python3
> from itertools import groupby > > def get_lines_from_file(file_name): > with open(file_name) as reader: > for line in reader.readlines(): > yield(line.strip()) > > counter = 0 > def key_func(x): > if x.startswith("Starting a new group"): > global counter > counter += 1 > return counter > > for key, group in groupby(get_lines_from_file("my_data"), key_func): > print(list(group)[1:]) > > Thank you for the responses! Not sure yet which one I will pick.
-- http://mail.python.org/mailman/listinfo/python-list