CSV file formats

This topic contains details of the format for comma separated variable (CSV) files used in importing, exporting or updating Networks and Control Data sets.

The following sections are included:

  1. General File Formatting Information
  2. Formatting Details for Specific Field Types
  3. Using Data Exported from InfoWorks WS Pro

General File Formatting Information

The way in which data is distributed between files is quite flexible:

Each file consists of a combination of:

Each file is treated as an individual entity. The data type delimiter and header record information is not carried forward from one file to another.

Data type delimiter

The data type delimiter takes the form of four stars followed by the name of the database table containing details of this type of network object.

Details of database table names can be found in the Network Data Fields section.

Example:

**** wn_node

The header delimiter can be omitted and filename used to denote object type instead by appending the table name minus the initial wn_ to the filename.

Example:

xxx_node.csv

tells InfoWorks WS Pro that the file begins with Node data.

Using the filename is a more visible way to organise your data if you have one network object type per file. This approach is used when you export from InfoWorks WS Pro using the Export each table to a different file option.

A filename can be used to define the data type at the start of a file and data type delimiters used to define different types further down the file, however this approach is unlikely to be of much benefit.

Deletes delimiter

The delimeter ****deletes can be used to define a list of objects to be deleted when updating a network. The delimiter is followed by a record for each object to be deleted containing table name and Asset ID of the object.

Example:

****deletes

ObjectTable, asset_id

wn_pipe, 28165073

wn_pipe, 28165094

wn_node, 10857075

wn_node, 10857076

Alternatively, append deletes to the filename to delete all objects in a file.

Note:

Header record

The header record contains a list of the field names contained in the database table for the network object.

For InfoWorks WS Pro the primary key fields are:

Nodes tables (Node, Transfer Node, Fixed Head Node, Hydrant, Reservoir, Well)

The primary key for nodes is the node_id field. This field contains a string up to 30 characters long. The ID must be unique within the network

Links tables (Pipe, Valve, Float Valve, Meter, Non-Return Valve, Pumping Station)

Links require three fields: upstream_node_id, downstream_node_id, and link_suffix. The combination of the three fields must be unique within the network.

Curves tables (Pump Curves, PRD  Curves, Valve Curves)

The primary key for pump curves is the ID field. This field contains a string up to 30 characters long. The ID must be unique within the network

Control Data tables form a similar pattern to the network tables. There is a control table for every node and link table in the network. (There is no control table for the wn_pump table as pumps actually form part of pumping stations and the control rules are implemented at the pumping station level.)

All records in the control data are associated with a node or link in a network. For this reason the primary key fields match. For simulation to proceed the associated node or pipe described in the Control Data primary key must exist in the network.

Data records

The header record is followed by zero or more data records.

Escape Characters

In certain circumstances it is necessary to use escape characters to maintain the structure of the exported data.

Formatting Details for Specific Field Types

Text fields

Text fields must be contained in double quotation marks if they contain commas or other double quotation marks. Otherwise quotation marks are optional.

Arrays of values of a single type

Arrays of values of a single type, such as coordinates, can be defined as packed (as a single field) or as unpacked (each value is defined in a separate field).

Packed

The array is defined in a single field consisting of an opening curly brace, followed by a comma separated list of values, followed by a closing curly brace.

Example - array defining bends in a pipe

{389956.,110970.,389997.,111017.,390146.,110934.,390661.,111197.}

{389956.,110970.,389923.,111048.,390117.,111259.,390309.,111765.}

Unpacked

The array is defined with each value in a separate field with column headers for the first of each value type.

Example:

xs

ys

 

 

 

 

 

 

389956

110970

389997

111017

390146

110934

390661

111197

389956

110970

389923

111048

390117

111259

390309

111795

 Arrays of values containing more than one field

These arrays contain lists of values that describe more complex parts of particular objects, for example:

The arrays can be defined as packed (as a single field) or separately (in a separate block or separate file).

Packed

Each array is defined in a single field:

Example - Node Demand:

This example defines demand at a node. Two sub-fields each define demand in one Demand category:

{{Tourism,,10.000000,0},{DomSumer,,13.300000,0}}

Each sub-field contains 4 values, which have to appear in the correct order. In this case the order is:

Separately

Each array is defined in a separate block or separate file. Each value in the array is defined in a separate field.

The Data Type Delimiter takes the form of four starts followed by the Database Data Structure name.

Details of Database Data Structure names can be found in the NetWork Data Fields section.

Example - Pump Curve

****wn_pump_triplets

 

 

 

id

flow

head

power

BPu-300

0

61.1

89.5

 

150

58

133

 

240

54.1

164.8

 

300

50

183.8

HP-200

0

48.5

46.7

 

100

46.2

70.5

 

200

40

98

 

300

22.3

117.5

 

Using Data Exported from InfoWorks WS Pro

When CSV files are exported from InfoWorks WS Pro, you have the option to export descriptive field names and units information. These are exported as additional records placed before the data records. If you export files including these additional records, and then try to import them, InfoWorks WS Pro will try to interpret the additional data as normal data records. You will almost certainly get error messages telling you that values in the file have the wrong size or type.

The additional export options are there for your convenience when viewing InfoWorks WS Pro data in other packages. You should make sure that data you intend to import back into InfoWorks WS Pro is exported without these additional records. The Select CSV Export Options dialog divides the options needed for re-import from the additional options and you should have no trouble exporting in the correct format. The additional records could also be removed by editing the file in another package prior to re-import.

Pruned sections of the network are not exported to CSV files. A Prune object is very complex, containing details of all the pruned links and nodes, as well as connectivity information.


Importing from CSV files