{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n" ] } ], "source": [ "import pandas as pd\n", "path = 'one_cycle.csv'\n", "df = pd.read_csv(path)\n", "\n", "# 적당히 지정하세요\n", "node_id = df['node_id'][0]\n", "offset = 999\n", "\n", "# xml양식대로 작성\n", "strings = ['\\n']\n", "strings.append(f' \\n')\n", "for i, row in df.iterrows():\n", " dur = row['dura']\n", " state = row['signal']\n", " strings.append(f' \\n')\n", "strings.append(' \\n')\n", "strings.append('')\n", "strings = ''.join(strings)\n", "print(strings)\n", "\n", "# 저장\n", "path_output = 'example.tll.xml'\n", "with open(path_output, 'w') as f:\n", " f.write(strings)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# netedit -s example.net.xml -i example.tll.xml" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [], "source": [ "sumo_config_content = \"\"\"\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\"\"\"\n", "\n", "with open('your_configuration_file.sumocfg', 'w') as file:\n", " file.write(sumo_config_content.strip())\n" ] } ], "metadata": { "kernelspec": { "display_name": "rts", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.10" } }, "nbformat": 4, "nbformat_minor": 2 }