Export to CSV files


The plug-in for exporting CSV files exports a network to a collection of CSV files, one file per node / link type, one file for network, one file for scenario. Time series and array values will each have its own file also.

Basic usage:

ExportCSV.py [-h] [-t NETWORK] [-z TIMEZONE]


Option Short Parameter Description
--help -h   show help message and exit.
--network_id -t NETWORK Specify the file containing network information. If no file is specified, a new network will be created using default values.
--scenario_id -s SCENARIO The scenario to be exported. If not specified all the scenarios in the network will be exported.
--output_folder -o OUTPUT The folder where the exported network is to be put. Defaults to Desktop.
--timezone -z TIMEZONE Specify a timezone as a string following the Area/Loctation pattern (e.g. Europe/London). This timezone will be used for all timeseries data that is exported. If you don’t specify a timezone, it defaults to UTC.
--server-url -u SERVER-URL Url of the server the plugin will connect to. Defaults to localhost.
--session-id -c SESSION-ID Session ID used by the callig software. If left empty, the plugin will attempt to log in itself.

File structure

For nodes, the following is an example of what will be exported:

Name , x, y, attribute_1, attribute_2, ..., attribute_n, description
Units,  ,  ,           m,    m^3 s^-1, ...,           -,
node1, 2, 1,         4.0,      3421.9, ...,  Crop: corn, Irrigation node 1
node2, 2, 3,         2.4,       988.4, ...,  Crop: rice, Irrigation node 2

For links, the following will be and example of what will be exported:

Name ,       from,       to, attribute_1, ..., attribute_n, description
Units,           ,         ,           m, ...,    m^2 s^-1,
link1,      node1,    node2,         453, ...,        0.34, Water transfer

The following network file will be exported:

ID, Name , attribute_1, ..., Description 1 , My first network, test , , A network create from CSV files


Add any other information here...

API docs

A Hydra plug-in for exporting a hydra network to CSV files.

class ExportCSV.ExportCSV(url=None, session_id=None)
export(network_id, scenario_id, output_folder)

Export a network (and possibly a scenario) to a folder. If the scenario and output folders are not specified, all the scenarios will be exported and the output location will be the desktop.

export_network(network, scenario)

Write the output files based on the given network and scenario.

export_resourcegroupitems(scenario, group_map, node_map, link_map)

Export the members of a group in a given scenario.

export_resourcegroups(scenario, resourcegroups, node_map, link_map)

Export resource groups into two files. 1:groups.csv defining the group name, description and any attributes. 2:group_members.csv defining the contents of each group for this scenario

export_rules(scenario, node_map, link_map, group_map)

Export rules, which are chunks of text associated with resources and a scenario. :param scenario object to retrive the ID :param node map to get the name of a node from its id :param link map to get the name of a link from its id :param group map to get the name of a group from its id.

get_attr_unit(scenario, attr_id, attr_name=None)

Returns the unit of a given resource attribute within a scenario

get_attr_value(scenario, resource_attr, attr_name, resource_name)

Returns the value of a given resource attribute within a scenario