Unverified Commit fba5024c authored by Marius van den Beek's avatar Marius van den Beek Committed by GitHub
Browse files

Merge pull request #18634 from mvdbeek/import_relabel_from_file_error_message

[24.1] Improve relabel identifiers message when number of columns is not 2
parents 745913df 2ae80c97
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -3812,8 +3812,14 @@ class RelabelFromFileTool(DatabaseOperationTool):
        if how_type == "tabular":
            # We have a tabular file, where the first column is an existing element identifier,
            # and the second column is the new element identifier.
            new_labels_dict = {}
            source_new_label = (line.strip().split("\t") for line in new_labels)
            new_labels_dict = dict(source_new_label)
            for i, label_pair in enumerate(source_new_label):
                if not len(label_pair) == 2:
                    raise exceptions.MessageException(
                        f"Relabel mapping file line {i + 1} contains {len(label_pair)} columns, but 2 are required"
                    )
                new_labels_dict[label_pair[0]] = label_pair[1]
            for dce in hdca.collection.elements:
                dce_object = dce.element_object
                element_identifier = dce.element_identifier