def parse_csv()

in mozci/console/commands/batch_execution.py [0:0]


    def parse_csv(self, reader):
        """
        Parse the CSV file and evaluate each classify result for a specific configuration and Push
        """
        pushes_group_summaries = {}
        pushes_sheriff_data = {}

        configs = {}
        for i, row in enumerate(reader, start=2):
            self.line(f"Evaluating line {i} of the CSV")
            config = ",".join(
                ["=".join([param, row[param]]) for param in PARAMETERS_NAMES]
            )

            if config not in configs:
                # Initialize all counts at 0
                configs[config] = {key: 0 for key in self.csv_header[1:]}

            configs[config]["total_pushes"] += 1

            if row["classification"] == "SYSTEM_ERROR":
                # No need to evaluate since an error happened during Push classification
                configs[config]["classify_errors"] += 1
                continue

            push_uuid = row["push_uuid"]
            try:
                branch, rev = push_uuid.split("/")
                push = Push(rev, branch=branch)

                if row["classification"] == PushStatus.GOOD.name:
                    if push.backedout:
                        configs[config]["wrong_good"] += 1
                    else:
                        configs[config]["correct_good"] += 1
                elif row["classification"] == PushStatus.BAD.name:
                    if push.backedout:
                        configs[config]["correct_bad"] += 1
                    else:
                        configs[config]["wrong_bad"] += 1

                if push_uuid not in pushes_group_summaries:
                    pushes_group_summaries[push_uuid] = push.group_summaries

                if push_uuid not in pushes_sheriff_data:
                    # By storing sheriffs annotations here, we will only have to run
                    # retrieve_sheriff_data once per push, since it can take a long
                    # time to fetch everything, this helps speed up the evaluation
                    pushes_group_summaries, sheriff_reals = retrieve_sheriff_reals(
                        pushes_group_summaries, push
                    )
                    (
                        pushes_group_summaries,
                        sheriff_intermittents,
                    ) = retrieve_sheriff_intermittents(pushes_group_summaries, push)
                    pushes_sheriff_data[push_uuid] = {
                        "reals": sheriff_reals,
                        "intermittents": sheriff_intermittents,
                    }

                evaluation = self.evaluate_push_failures(
                    push.id,
                    row["run_uuid"],
                    pushes_group_summaries[push_uuid],
                    pushes_sheriff_data[push_uuid],
                )
                for key, value in evaluation.items():
                    configs[config][key] += value

            except Exception as e:
                configs[config]["evaluate_errors"] += 1
                self.line(
                    f"<error>An error occurred during the evaluation of the classify execution with run_uuid {row['run_uuid']}: {e}</error>"
                )

        return configs