CSV Export Procedure

This procedure is used to export the result of a query into a CSV file.

Configuration

A new procedure of type export.csv named <id> can be created as follows:

mldb.put("/v1/procedures/"+<id>, {
    "type": "export.csv",
    "params": {
        "exportData": <InputQuery>,
        "dataFileUrl": <Url>,
        "headers": <bool>,
        "delimiter": <string>,
        "quoteChar": <string>,
        "skipDuplicateCells": <bool>,
        "runOnCreation": <bool>
    }
})

with the following key-value definitions for params:

Field, Type, DefaultDescription

exportData
InputQuery

An SQL query to select the data to be exported. This could be any query on an existing dataset.

dataFileUrl
Url

URL where the csv file should be written to. If a file already exists, it will be overwritten.

headers
bool
true

Whether to print headers

delimiter
string
","

The delimiter to place between each value

quoteChar
string
"\""

The character to enclose the values within when they contain either a delimiter or a quoteChar

skipDuplicateCells
bool
false

The CSV format cannot represent many values per cell the way MLDB datasets can by using the time dimension. When this parameter is set to false, an exception will be thrown when the export procedure detects many values for the same row/column pair.

To export a dataset that has more than one value in at least one cell, there are two options:

  • Set this parameter to true, which will pick one in an undetermined way.
  • Apply a temporal aggregator, like temporal_max(), to the values. See the Built-in Functions documentation for the complete list of aggregators.

runOnCreation
bool
true

If true, the procedure will be run immediately. The response will contain an extra field called firstRun pointing to the URL of the run.