From eb09b8126594561849c692380bb5e0249474b08d Mon Sep 17 00:00:00 2001 From: Up Chen Date: Sat, 9 Nov 2019 22:08:10 +0800 Subject: [PATCH] Use names to locate the attributes instead of using the index. --- xml_to_csv.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/xml_to_csv.py b/xml_to_csv.py index 03692c4cfa0..6621be690bb 100644 --- a/xml_to_csv.py +++ b/xml_to_csv.py @@ -35,13 +35,13 @@ def xml_to_csv(path): classes_names.append(member[0].text) value = ( root.find("filename").text, - int(root.find("size")[0].text), - int(root.find("size")[1].text), - member[0].text, - int(member[4][0].text), - int(member[4][1].text), - int(member[4][2].text), - int(member[4][3].text), + int(root.find("size").find("width").text), + int(root.find("size").find("height").text), + member.find("name").text, + int(member.find("bndbox").find("xmin").text), + int(member.find("bndbox").find("ymin").text), + int(member.find("bndbox").find("xmax").text), + int(member.find("bndbox").find("ymax").text), ) xml_list.append(value) column_name = [