webCOMAND

Import

Content can be imported from external data sources from the Import option in the Collection Toolbar.

The following import formats are supported.

  • CSV - Comma separated values format.
  • cJSON - COMAND JavaScript Object Notation format.
  • ZIP - Zip file archive format.

CSV

Comma-separated values (CSV) files contain plain-text with commas to separate values, and newlines to separate records.  If the value or record delimiters may appear within a value, values can be surrounded with double-quotes (e.g. "Trains, Planes and Automobiles").  If the value contains one or more double-quotes, the value should be surrounded by double-quotes and all double-quotes in the value should become two double-quotes (e.g. "My favorite Seinfeld episode is ""The Puffy Shirt.""").

The first line in a CSV must include a comma-separated list of Field Identifiers that correspond to the fields of the Content Type of the objects that should be imported.

Values must be in the following formats based on their Field Type:

Data

  • Checkboxes - 0 or empty string means "unchecked" and 1 means "checked"
  • Color - An RGB hex triplet web color (#RRGGBB).
  • Dates - Typically "YYYY-MM-DD" format, but any format recognized by strtotime() can be used.
  • Times - Typically "HH:MM:SS" format, but any format recognized by strtotime() can be used.
  • Timestamps - Typically "YYYY-MM-DD HH:MM:SS" format, but any format recognized by strtotime() can be used.
  • File - A URL or relative to a local file path (including "files/filename.ext" in a ZIP file import).
  • Image - See File above.
  • Number - The numeric value, which may include thousands separators and a decimal.
  • Text - Plain Text, Rich Text and Source Code follow the standard CSV rules detailed above.

Relationships

Values for Relationship Fields that reference another object can be one of the following.

  • cQuery - A cQuery statement, which may include cPath and/or cQL.  Keep in mind that an OID, DOID and UUID values are all valid cPaths.
  • Key=Value - A unique/key field followed by an equal sign (=) and corresponding value.
  • Object Key - The cObject Key.

If the Relationship Field can reference multiple objects, the value should follow the standard CSV rules detailed above (e.g. "15202,15204" and """Key with 'single quotes', commas and "double-quotes""", Key 2").

Example: presidents.csv

ID, OID, UUID, Type, Number, Name, Photo, PreviousPresident
13, 2458, 550e8400-e29b-41d4-a716-446655440013, 550e8400-e29b-41d4-a716-446655440123, 1, George Washington, files/1.jpg,
15, 2460, 550e8400-e29b-41d4-a716-446655440015, 550e8400-e29b-41d4-a716-446655440123, 2, John Adams, files/2.jpg, 2458

cJSON

See cJSON.

Example: presidents.cjson

/**
 * Presidents - Some presidents with photos.
 */
{
    "type": "COMAND",
    "version": "1.0",
    "title": "Presidents",
    "description": "Some presidents with photos.",
    "source": "https://demo.webcomand.com/",
    "time": "2013-10-16T15:39:25+0400",
    "contents": [
        {
            "ID": 13,
            "OID": 2458,
            "UUID": "550e8400-e29b-41d4-a716-446655440013",
            "Type": {"UUID": "550e8400-e29b-41d4-a716-446655440123"},
            "Number": 1,
            "Name": "George Washington",
            "Photo": {"type": "url", "value": "files/1.jpg"},
            "Previous President": null
        },
        {
            "ID": 15,
            "OID": 2460,
            "UUID": "550e8400-e29b-41d4-a716-446655440015",
            "Type": {"UUID": "550e8400-e29b-41d4-a716-446655440123"},
            "Number": 2,
            "Name": "John Adams",
            "Photo": {"type": "url", "value": "files/2.jpg"},
            "Previous President": {"UUID": "550e8400-e29b-41d4-a716-446655440013"},
        }
    ]
}

ZIP

A zip file import is useful when it makes sense to include additional files for binary data, such as images, or even text files that are easier to manage as independent files.

Zip file imports must include:

  • One top-level folder named "contents"
  • One file with a filename that matches the zip filename, except with the file extension that matches the format of the main import (e.g. "csv" or "cjson").
  • One sub-folder named "files" that contains all supporting files referenced by the main import file (see previous bullet).

For details about how to reference the support files in the files sub-folder, see the format above.

Example: presidents.zip

The following example just represents the folder and files within a zip import file.  The contents of the files are detailed in the sections above.

  • contents
    • files
      • George-Washington-42739-Photo.jpg
      • John-Adams-42752-Photo.jpg
    • presidents.csv
Developers may be interested in the Import/Export Tutorial.