Skip to content

Added tools/detector/DetectorsOutToTable.py script#17923

Closed
davide990 wants to merge 1 commit intoeclipse-sumo:mainfrom
davide990:detectors_out_to_table
Closed

Added tools/detector/DetectorsOutToTable.py script#17923
davide990 wants to merge 1 commit intoeclipse-sumo:mainfrom
davide990:detectors_out_to_table

Conversation

@davide990
Copy link
Copy Markdown
Contributor

Added tools/detector/DetectorsOutToTable.py script. This is to convert detectors output in XML to a tabular format, ideal for data analysis tasks or for loading data as dataframe.

For sake of example, if you have a detectors output in typical XML format:

<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/det_e1meso_file.xsd">
    <interval begin="0.00" end="3600.00" id="BXLAND031448F1_0" sampledSeconds="2.02" density="0.04" laneDensity="0.04" occupancy="0.02" waitingTime="0.00" timeLoss="0.00" speed="7.08" speedRelative="0.85" departed="0" arrived="0" entered="1" left="1"/>
    <interval begin="0.00" end="3600.00" id="BXLAND031450F1_0" sampledSeconds="0.00" departed="0" arrived="0" entered="0" left="0"/>
    <interval begin="0.00" end="3600.00" id="BXLAND031450F1_1" sampledSeconds="0.00" departed="0" arrived="0" entered="0" left="0"/>
    <interval begin="0.00" end="3600.00" id="BXLAND031451F1_0" sampledSeconds="0.14" density="0.04" laneDensity="0.02" occupancy="0.01" waitingTime="0.00" timeLoss="0.00" speed="13.24" speedRelative="0.95" departed="0" arrived="0" entered="2" left="2"/>
    <interval begin="0.00" end="3600.00" id="BXLAND031451F1_1" sampledSeconds="0.14" density="0.04" laneDensity="0.02" occupancy="0.01" waitingTime="0.00" timeLoss="0.00" speed="13.24" speedRelative="0.95" departed="0" arrived="0" entered="2" left="2"/>

then by using this script you can convert this into a tabular CSV in this format

ts	BXLAND031448F1	BXLAND031450F1	BXLAND034219F1	BXLAND034220F1
0	6	2	0	0
3600	5	4	6	0
7200	2	0	3	0
10800	6	6	12	0
14400	29	10	33	0
18000	44	32	90	0
21600	116	128	168	9

…t detOut in XML to a tabular format, ideal for data analysis tasks or for loading data as dataframe.
@behrisch
Copy link
Copy Markdown
Contributor

Thanks for sharing! But I don't think we will merge this. Sumo has already csv and parquet output to facilitate these use cases.

@behrisch behrisch closed this May 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants