You have all the information in the printed results. The
nodo.attrib
is a standard Python dictionary of all the attributes of the node. See
Built-in Types — Python 3.11.0 documentation[
^] for the methods of dictionaries.
[edit]
Starting with a list of all your dictionary items, something like:
stuff = [{'id': '1372839298', 'event_id': '3', 'type_id': '1', 'period_id': '1', 'min': '0', 'sec': '1', 'player_id': '37572', 'team_id': '43', 'outcome': '1', 'x': '50.1', 'y': '50.0', 'timestamp': '2011-08-21T16:00:40.179', 'last_modified': '2011-08-21T16:00:41'},
{'id': '978322590', 'event_id': '4', 'type_id': '1', 'period_id': '1', 'min': '0', 'sec': '2', 'player_id': '20664', 'team_id': '43', 'outcome': '1', 'x': '48.2', 'y': '49.1', 'timestamp': '2011-08-21T16:00:41.585', 'last_modified': '2011-08-21T16:00:44'},
{'id': '1962550717', 'event_id': '7', 'type_id': '1', 'period_id': '1', 'min': '0', 'sec': '19', 'player_id': '42593', 'team_id': '43', 'outcom': '1', 'x': '48.2', 'y': '49.1', 'timestamp': '2011-08-21T16:00:41.585', 'last_modified': '2011-08-21T16:00:44'} ]
newlist = []
keys = [ 'period_id', 'min', 'sec', 'player_id', 'team_id' ]
for d in range(len(keys)):
newlist.append([])
for dicts in stuff:
for k in range(len(keys)):
newlist[k].append(dicts[keys[k]])
print(newlist)
[/edit]