Skip to content

Commit

Permalink
Now computeStoppingPlaceUsage.py can write in csv format. Refs #8405
Browse files Browse the repository at this point in the history
  • Loading branch information
palvarezlopez committed Mar 24, 2021
1 parent 2d3fdf7 commit ab2917c
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions tools/output/computeStoppingPlaceUsage.py
Expand Up @@ -36,6 +36,8 @@ def get_options(args=None):
help="output route file with stops")
optParser.add_option("-s", "--stopping-place", dest="stoppingPlace",
help="stoppingPlace Type (busStop, parkingArea...)", default="parkingArea")
optParser.add_option("-c", "--csv", dest="csv",
help="write in CSV format", default="")
(options, args) = optParser.parse_args(args=args)
if not options.stopOutput:
optParser.print_help()
Expand All @@ -61,16 +63,27 @@ def main(options):
tPrev = None
count = 0
# write header
outf.write("<?xml version= \"1.0\" encoding=\"UTF-8\"?>\n\n")
# open route rag
outf.write("<stoppingPlace>\n")
if (options.csv):
# write CSV header
outf.write("step,number\n")
else:
# write XML header
outf.write("<?xml version= \"1.0\" encoding=\"UTF-8\"?>\n\n")
# open route rag
outf.write("<stoppingPlace>\n")
# iterate over trips
for t,change in times:
if t != tPrev and tPrev is not None:
outf.write(" <step time=\"%s\" number=\"%s\"/>\n" % (tPrev, count))
if (options.csv):
outf.write("%s,%s\n" % (tPrev, count))
else:
outf.write(" <step time=\"%s\" number=\"%s\"/>\n" % (tPrev, count))
count += change
tPrev = t
outf.write(" <step time=\"%s\" number=\"%s\"/>\n" % (t, count))
if (options.csv):
outf.write("%s,%s\n" % (tPrev, count))
else:
outf.write(" <step time=\"%s\" number=\"%s\"/>\n" % (t, count))
# close route tag
outf.write("</stoppingPlace>\n")

Expand Down

0 comments on commit ab2917c

Please sign in to comment.