#!/usr/bin/env python1# Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2# Copyright (C) 2008-2026 German Aerospace Center (DLR) and others.3# This program and the accompanying materials are made available under the4# terms of the Eclipse Public License 2.0 which is available at5# https://www.eclipse.org/legal/epl-2.0/6# This Source Code may also be made available under the following Secondary7# Licenses when the conditions for such availability set forth in the Eclipse8# Public License 2.0 are satisfied: GNU General Public License, version 29# or later which is available at10# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later1213# @file CSV2polyconvertXML.py14# @author Daniel Krajzewicz15# @author Michael Behrisch16# @date 2008-07-171718"""19Converts a given CSV-file that contains a list of pois to20an XML-file that may be read by POLYCONVERT.21"""22from __future__ import absolute_import23from __future__ import print_function2425import sys2627if len(sys.argv) < 4:28print("Error: Missing argument(s)")29print(30"Call: CSV2polyconvertXML.py <CSV_FILE> <OUTPUT_FILE> <VALUENAME>[,<VALUENAME>]*")31print(" The values within the csv-file are supposed to be divided by ';'.")32print(33" <VALUENAME>s give the attribute names in order of their appearance within the csv-file .")34exit()353637names = sys.argv[3].split(',')38inpf = open(sys.argv[1])39outf = open(sys.argv[2], "w")40outf.write("<pois>\n")41for line in inpf:42if len(line) == 0 or line[0] == '#':43continue44vals = line.strip().split(';')45outf.write(" <poi")46for i, n in enumerate(names):47outf.write(' ' + n + '="' + vals[i] + '"')48outf.write("/>\n")49outf.write("</pois>\n")50inpf.close()51outf.close()525354