Hello

thank you for the reply

I have try many times to adapt the python script but I still don't get the
correct form

import os,sys
sys.path.append(os.path.join(os.environ["SUMO_HOME"], "tools"))
import sumolib
for v in sumolib.output.parse(sys.argv[1], "vehicle"):
if v.route==None:
  print(v.routeDistribution[0].route[-1].edges.split())
else
print (v.route[0].edges.split())

I get this error

File "convert_to_edgeonlywithouttime.py", line 5
    if v.route==None:
     ^
IndentationError: expected an indented block

I don't how to correct this error

Best regards


2016-04-27 8:17 GMT+02:00 Jakob Erdmann <[email protected]>:

> check if v.route is None and then use
> v.routeDistribution[0].route[-1].edges.split()
> instead of v.route[0].edges.split()
>
> 2016-04-26 1:56 GMT+02:00 mima Line <[email protected]>:
>
>> hello sumo users,
>>
>> i get helped in my previous message with how using vehroute and how to
>> parse the output file contaning the edges
>> these steps works perfectly with Bologna scenario
>>
>> ======but with Lust scenario I get a problem
>>
>> Traceback (most recent call last):
>>
>>   File "convert_to_edgeonlywithouttime.py", line 5, in <module>
>>
>>     print(v.route[0].edges.split())
>>
>> TypeError: 'NoneType' object has no attribute '__getitem__'
>>
>>
>>
>> ======to use vehroute I have writen
>>
>> sumo -c sumo -c LuSTScenario.complete.mobility.sumo.cfg --vehroutes
>> out-Lust.xml
>>
>>
>> ======I have tested this python
>>
>> import os,sys
>>
>> sys.path.append(os.path.join(os.environ["SUMO_HOME"], "tools"))
>>
>> import sumolib
>>
>> for v in sumolib.output.parse(sys.argv[1], "vehicle"):
>>
>>   print(v.route[0].edges.split())
>>
>>
>> I have notice that the structure of my XML file is like that
>>
>> =======for some vehicles is
>>
>> <vehicle id="randUni834:1" type="passenger2b" depart="5.00"
>> arrival="58.00">
>>
>>         <route edges="-32624 -32144 --31050 --32406#3 --32406#2 --32406#1
>> --31212"/>
>>
>>     </vehicle>
>>
>>
>>
>> ======and in the other
>>
>> <vehicle id="0DEtoFR.4" type="passenger2a" depart="154.00"
>> arrival="626.00">
>>
>>         <routeDistribution>
>>
>>             <route replacedOnEdge="" replacedAtTime="154.00"
>> probability="0" edges="-31622#0 -31622#0-AddedOffRampEdge -31694 -31242
>> -32770#5 -32770#6 -32278#0 -32278#1 -32278#2 -32278#3 -32278#4 -32278#5
>> -32278#6 --30620 -31504#0 -31504#1 -31504#2 -30962#0 -30962#1 -30962#2
>> --30892 -30892#0 -30892#1 -30892#2 -30892#3 -30892#4 -30892#5 -30892#6
>> -30892#7 -30892#8 -30892#9 -30892#10 -30892#11 -30892#12 -30892#13
>> -30892#14 -30892#15 -30892#16 -31272#7 -31272#8 -31690 -32858#0
>> -32858#1-AddedOnRampEdge -32858#1 -32858#1-AddedOffRampEdge -32858#2
>> -31366#0-AddedOnRampEdge -31366#0 -31366#1-AddedOnRampEdge -31366#1
>> -31366#1-AddedOffRampEdge -31366#2 -31366#3-AddedOnRampEdge -31366#3"/>
>>
>>             <route edges="-31622#0 -31622#0-AddedOffRampEdge -31622#1
>> -31622#2-AddedOnRampEdge -31622#2 -31622#2-AddedOffRampEdge -31622#3
>> -31622#4-AddedOnRampEdge -31622#4 -31622#4-AddedOffRampEdge -31622#5
>> -31622#5-AddedOffRampEdge -31622#6 -31622#7-AddedOnRampEdge -31622#7
>> -31622#7-AddedOffRampEdge -31622#8 -31622#8-AddedOffRampEdge -30482
>> -31366#1-AddedOnRampEdge -31366#1 -31366#1-AddedOffRampEdge -31366#2
>> -31366#3-AddedOnRampEdge -31366#3"/>
>>
>>         </routeDistribution>
>>
>>
>> I think my problem is in parsing this two style of vehicle declaration in
>> the XML file
>>
>> Thanks for any help in this topic
>>
>> Best regards
>>
>> ------------------------------------------------------------------------------
>> Find and fix application performance issues faster with Applications
>> Manager
>> Applications Manager provides deep performance insights into multiple
>> tiers of
>> your business applications. It resolves application problems quickly and
>> reduces your MTTR. Get your free trial!
>> https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
>> _______________________________________________
>> sumo-user mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/sumo-user
>>
>
>
------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
_______________________________________________
sumo-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sumo-user

Reply via email to