Data Upload

Tablo is built around the idea of being able to upload a CSV file and then consuming that data through one or more generic interfaces that abstract out the data storage layer. Before you can consume the data, you must upload it into Tablo. This document details the steps involved in the upload process.

There are multiple steps to the process, allowing for minor changes in data along the way. The minimum set of steps is as follows:

  1. Upload CSV File
  2. Describe the CSV File
  3. Deploy the CSV File
  4. Create the Feature Service
  5. Finalize the Feature Service

Upload

TemporaryFileUploadUrlView.dispatch(request, *args, **kwargs)

Uploads a CSV file, based on URL and stores it under a UUID, allowing it to be referenced later. Send a POST message to {tablo-server}/tablo/admin/upload-by-url, with a parameter of url specifying where your file resides.

Keyword Arguments:
 
url

The URL of the file you wish to upload-by-url

Returns:

A JSON object in the following format:

{
    "uuid": "uniqueIdentifierForTheFile"
}

Describe

TemporaryFileResource.describe(request, **kwargs)

Describe, located at the {tablo-server}/api/v1/temporary-files/{uuid}/describe endpoint, will describe the uploaded CSV file. This allows you to know the column names and data types that were found within the file.

Returns:A JSON object in the following format:
{
    "fieldNames": ["field one", "field two", "latitude", "longitude"],
    "dataTypes": ["String", "Integer", "Double", "Double"],
    "optionalFields": ["field one"],
    "xColumn": "longitude",
    "yColumn": "latitude",
    "filename": "uploaded.csv"
}
fieldNames
A list of field (column) names within the CSV
dataTypes
A list of data types for each of the columns. The index of this list will match the index of the fieldNames list.
optionalFields
A list of fields that had empty values, and are taken to be optional.
xColumn
The best guess at which column contains X spatial coordinates.
yColumn
The best guess at which column contains Y spatial coordinates.
filename
The name of the file being described

Deploy

TemporaryFileResource.deploy(request, **kwargs)

The deploy endpoint, at {tablo_server}/api/v1/temporary-files/{uuid}/{dataset_id}/deploy/ deploys the file specified by {uuid} into a database table named after the {dataset_id}. The {dataset_id} must be unique for the instance of Tablo.

With the deploy endpoint, this is the start of what Tablo considers an import. The data will be temporarily stored in an import table until the finalize endpoint for the dataset_id is called.

POST messages to the deploy endpoint should include the following data:

csv_info
Information about the CSV file. This is generally that information obtained through the describe endpoint, but can be modified to send additional information or modify it.
fields

A list of field JSON objects in the following format:

{
    "name": "field_name",
    "type": "text",
    "value": "optional value",
    "required": true
}

The value can be specified if the field is a constant value throughout the table. This can be use for adding audit information.

Returns:An empty HTTP 200 response if the deploy was successful. An error response if otherwise.

Create a Feature Service

class tablo.api.FeatureServiceResource(api_name=None)

The FeatureService resource, located at {tablo_server}/api/v1/featureservice, allows you to create, edit and delete feature services within Tablo.

Once your data has been deployed through the deploy endpoint, you can create a feature service by sending a POST message to the above endpoint with data structured as:

{
    "description": "",
    "copyright_text": "",
    "spatial_reference": "{'wkid': 3857}",
    "units": "esriMeters",
    "allow_geometry_updates": false,
    "layers": [
        {
            "layer_order": 0,
            "table": "db_dataset_id_import",
            "name": "layername",
            "description": null,
            "geometry_type": "esriGeometryPoint",
            "supports_time": false,
            "start_time_field": null,
            "time_interval": 0,
            "time_interval_units": null,
            "drawing_info": {
                "renderer": {
                    "description": "",
                    "label": "",
                    "symbol": {
                        "angle": 0,
                        "color": [255, 0, 0, 255],
                        "size": 5,
                        "style": "esriSMSCircle",
                        "type": "esriSMS",
                        "xoffset": 0,
                        "yoffset": 0
                    },
                    "type": "simple"
                }
            }
        }
    ]
}

drawing_info contains ESRI styling for the FeatureService geometry type. The creation will return a URL that will contain the Service ID of your newly created feature service.

Finalize the Service

FeatureServiceResource.finalize(request, **kwargs)

The finalize endpoint, located at {tablo_host}/api/v1/featureservice/{service_id}/finalize. It allows you to finalize the feature service and mark it as available for use. This endpoint moves the data from the temporary database table and into its permanent one. It is accessed with a service_id parameter specifying the ID of the service you want to finalize.