Skip to main content

Comma-Separated Values (CSV)

CSV files are used in the system from multiple point of views. The system reads CSV files and infers on of the following separators: comma ,, semicolon ;, space , or tabulator \t.

The system creates CSV files for simulation. Below is a description for both use cases.

How to assign agent attribute values with data from a CSV file?

In the simulation configuration file (see this article for more information), an agent initialization file can be specified for each agent type. The file needs to contain a header row with attribute names (note: these names must match the attribute names in the corresponding agent type class). Each subsequent row is used to assign values to one agent's attributes. If the CSV file contains fewer rows than the number of agents instantiated at the beginning of the simulation, then the initialization file will loop back to the first row until all agents' attributes have values.

Here is an example of an agent initialization file:

genderlengthageworkerpartTimeWorkeraverageSpeedspeedpositionheightwidthmass
10.2229TrueFalseTrue01.70.4665
00.2226TrueTrueTrue01.720.4675.35
10.2233TrueFalseTrue01.710.4666.94
10.2249TrueTrueTrue01.710.4662.51
10.2255TrueFalseTrue01.720.4671.06
10.2219TrueTrueTrue01.710.4669.06
10.2327TrueFalseTrue01.750.4762.04
00.2229TrueFalseTrue01.720.4689
00.2228TrueFalseTrue01.720.4694.97
10.2250TrueFalseTrue01.70.4671.41

Columns are mapped automatically to the input attributes of the agent when using the AgentManager. More about spawning can be found here.

How to store simulation output data in a CSV file?

Simulation output data can be stored in a CSV file. For more information on this and on how to store data in a database, please click here.

Here is an example of a simulation output file:

TickStepDateTimeAccelerationActiveCapabilityActualTravelTimeBearingCurrentlyCarDrivingDistanceStartGoalExpectedTravelTimeGenderGoalXGoalY
3653652020-01-01T00:06:050Walking36369.97634115090324False539.1496372361638362Female9.950722453.5449285
485648562020-01-01T01:20:560Walking4170False447.5835438681768418Male9.950387853.5444032
635963592020-01-01T01:45:590Walking539246.87714679703578False796.4590189678215482Male9.944376253.5506118
679867982020-01-01T01:53:180Walking2980False715.490939532274331Female9.943022553.5518429
750675062020-01-01T02:05:060Walking840False63.4218008182423685Male9.942710953.5518512
774877482020-01-01T02:09:080Walking2080False227.9140326289338209Female9.945415353.5468596
782678262020-01-01T02:10:260CarDriving2080False497.89803147717004206Male9.947960153.5535065
11152111522020-01-01T03:05:520Walking578356.9962451289335False254.03827739817234595Male9.937673353.5440066
11644116442020-01-01T03:14:040Walking6135.22416886964015False5.32130839289737357Male9.951704653.5605164
11743117432020-01-01T03:15:430Walking120False15.26697153642333613Female9.943812953.5508932
12216122162020-01-01T03:23:360Walking785263.5532996107888False564.1441930826505792Female9.934791853.5475968

Depending on operating system setting and application settings (e.g., Excel), the separator/delimiter in CSV files are not identified correctly. This might lead to incorrect column separations while reading the file at the beginning of a simulation (agent initialization) or writing data into the file at the end of the simulation (simulation output data). To learn how to avoid this issue, please check out the section "CSV" in this tutorial.