def parse_content(lines: List[str]):
    _lines = list(filter(lambda x: x.strip(), lines))
    content = []

    for line in chunks(_lines, 2):
        content.append([*parse_meter(line[0]), *parse_no_by_category(line[1])])

    return content
예제 #2
0
def parse_ps_e(reports: List[Report]):
    ps_e = group_by_meter(reports)

    ps_e_parse = list()

    for meter, reports_ in ps_e.items():
        report_parsed = [[meter, *Cat]]
        slices = get_slices(reports_[0].report[7])
        for meter_group in chunks(reports_[0].report[9:], 7):
            for line in meter_group[:-1]:
                report_parsed.append([line[x].strip() for x in slices])
        for meter_group in chunks(reports_[1].report[5:32], 7):
            for line in meter_group[:-1]:
                report_parsed.append([line[x].strip() for x in slices])
        ps_e_parse.extend(report_parsed)

        summery_slices = get_summery_slices()
        summery_parsed = [['Summery', *Cat]]
        for line in reports_[1].report[34:]:
            summery_parsed.append([line[x].strip() for x in summery_slices])
        ps_e_parse.extend(summery_parsed)
    return ps_e_parse
def parse_contents(lines: List[str]):
    content = []
    counter = None

    for i, [l_1, l_2, l_3] in enumerate(chunks(lines, 3)):
        if l_1 == "\n" and l_2 == "\n" and l_3 == "\n":
            counter = i

            break
        else:
            meter = PATTERN_METER.search(l_1).groupdict().values()
            no_by_category = PATTERN_NO_BY_CATEGORY.search(
                l_2).groupdict().values()
            content.append([*meter, *no_by_category])

    total = []

    for line in lines[(counter + 1) * 3:]:
        total.append(list(PATTERN_TOTAL_ENERGY.search(line).groups()))

    return [*content, *total]
예제 #4
0
def parse_content(lines: List[str]):
    return list(
        map(
            lambda x: [*parse_meter(x[0]), *parse_no_by_category(x[1])],
            chunks(list(filter(lambda x: x.strip(), lines)), 2),
        ))