def string2fields(string, lengths):
    """Slice string into fixed-length fields."""
    return (string[pos:pos + length].strip()
            for idx, length in enumerate(lengths)
            for pos in [sum(map(int, lengths[:idx]))])