Comma-Separated Value Files

Corda Server™ can load comma-separated value (CSV) files, which are very common and can be exported by most database and spreadsheet applications. CSV files only support data, and not formatting options or data annotations.

This section is divided into the following topics:

Formatting Data

In CSV files, each data cell is delimited by a comma, and each row is delimited by a line break. Upon import, Corda Server translates these files directly into a spreadsheet.

When preparing CSV data files, organize the data in tables consistent with the spreadsheet format used by Corda Builder's Data Editor. For more information about organizing data, see Graph Data and About Maps in the Corda Builder™ User Guide.

For non-standard graph types (X-Y and Time Plots), see Data Organization in the Corda® 7 Graph Guide.

Graphs

The example below demonstrates a table of CSV data.

Example Data in Comma Separated Values Format (Graphs)

City,Arrivals,Departures,Unused,Out of Commission

Atlanta,23,36,11,7

Boston,41,17,25,9

If a graph uses data categories, the file can also be organized as shown in the example below, where each row of data represents a single data value. For more information, see Alternative Data Organization Format in the Corda 7 Graph Guide.

Example Data in Alternative CSV Format (Graphs)

Atlanta,Arrivals,23

Atlanta,Departures,36

Atlanta,Unused,11

Atlanta,Out of Commission,7

Boston,Arrivals,41

Boston,Departures,17

Boston,Unused,25

Boston,Out of Commission,9

Maps

The example below demonstrates map data in CSV format.

Example Data in Comma Separated Values Format (Maps)

City,Arrivals

Adelaide,23

Brisbane,78

Canberra,1

Darwin,55

Hobart,25

Melbourne,71

Perth,9

Sydney,52

Note: The first row contains optional header information that is not used by Corda Server except in support of meta tags (or macros). For more information, see META Tags.

Each row represents a separate map data item. The first column identifies the map shape to which the data value belongs, while the second column specifies the actual value.

If it's necessary to identify map items by names other than the one specified in the name attribute of the map shape, use its long-name or code attribute instead. For example, a database might store information for a TX object under Texas, or a database might use FIPS codes instead of county or state names.

Any map data items referenced in the data file must already be defined in the Image Template file, or Corda Server ignores all data associated with that reference.

For information about adding map shapes to a map, see Adding Point Layer Data Items and Adding Area Data Items in the Corda Builder User Guide.

Importing with Corda Embedder

To import CSV data files into graphs, use the loadData() method. To import CSV data files into maps, use the loadMapData() method. Both function in the same manner, as described below.

Important: In order for Corda Server to load any kind of file or data source, it must be given permission to read data from the specified path or domain. For more information, see Setting Path Permissions in the Corda 7 Install and Administration manual.

Graphs

The loadData() method accepts two parameters for CSV data:

Important: ASP/VBScript requires five parameters. The last three parameters are empty strings (““).

For example, to load a data file named <document_root>\data\prices.dat, use the following Corda Embedder method call:

myImage.loadData("graph","data/prices.dat");

Similarly, to load data from a Web application at http://Webapp.mycompany.com/getdata, use the following Corda Embedder method call:

myImage.loadData("graph","http://Webapp.mycompany.com/getdata?year=2002");

Note: The code above assumes a Corda Embedder object named myImage.

Maps

The loadMapData() method accepts three parameters for CSV data:

Important: ASP/VBScript requires five parameters. The last two parameters are empty strings (““).

For example, to load a data file named <document_root>\data\prices.dat, use the following Corda Embedder method call:

myImage.loadMapData("map","Area","data/prices.dat");

Similarly, to load data from a Web application at http://webapp.mycompany.com/getdata, use the following Corda Embedder method call:

myImage.loadMapData("US","Points","http://webapp.mycompany.com/getdata?year=2002");

Note: The code above assumes a Corda Embedder object named myImage.