Geovisualization Developer's Guide

trim

When you use this function in a query, it removes characters on the left and right side of the strings in the specified column in the specified dataset.

For more information on using query functions and operators in a REST API request, see Queries. For an end-to-end description of how to create a query, see Creating a Query.

The codeblock example below removes the leading and trailing spaces of the strings in the Region column of the earthquake dataset, whose {DATASET_ID} is 90af668484394fa782cc103409cafe39.

{
  "version": 0.3,
  "dataset": "90af668484394fa782cc103409cafe39",
  "namespace": {
    "trim": {
      "source": ["Region"],
      "apply": [{
        "fn": "trim", 
        "type": "transform",
      }]
    }
  },
  "metrics": ["trim"],
}
Use the params key to specify the removal of specific characters, the example below removes the C character from the beginning and end of a string:
{
  "version": 0.3,
  "dataset": "90af668484394fa782cc103409cafe39",
  "namespace": {
    "trim": {
      "source": ["Region"],
      "apply": [{
        "fn": "trim", 
        "type": "transform",
        "params": ["C"],
      }]
    }
  },
  "metrics": ["trim"],
} 

When you submit the above request, the response includes an HTTP status code and a JSON response body.

For more information on the HTTP status codes, see HTTP Status Codes.

For more information on the elements in the JSON structure in the response body, see Query.