Example: Using a CSV Schema - Advanced SQL Engine - Teradata Database

DATASET Data Type

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Published
July 2021
Language
English (United States)
Last Update
2021-07-27
dita:mapPath
amv1590702100517.ditamap
dita:ditavalPath
amv1590702100517.ditaval
dita:id
B035-1198
lifecycle
previous
Product Category
Teradata Vantageā„¢

The following example contains attributes based on some optional parameters.

{
      "field_names" : <JSON array with column names >,
      "field_delimiter" : <field_delimiter_character>,
      "record_delimiter" : <record_delimiter_character>
}

Another example of the schema:

{
      "field_names" : ["name","dob","phone","address"],
      "field_delimiter" : ",",
      "record_delimiter" : "\r\n"
}

Note that the key names field_names, field_delimiter, and record_delimiter must be specified exactly as shown to be correctly interpreted. The names are also case-sensitive.

There are three options when specifying a header for CSV data using this schema format:
  1. The field_names key/value pair is omitted. This tells the database there is a header record in the CSV data.
  2. The field_names key/value pair is included, but its value is a JSON null. This tells the database that there is no header included in the CSV data, and that you do not want to provide one. In this case, the database auto-generates names for the fields of the CSV file, according to the format:
    csv_fld1, csv_fld2, csv_fld3, ... , csv_fldN
  3. The field_names key/value pair is included, and its value is a JSON array of strings. This tells the database there is no header in the CSV data, and that you want to specify the names of the fields by using this schema.

Based on the schema, the data is expected to be a set of characters where fields are divided by the field_delimiter and records are divided by the record_delimiter. The following example shows CSV data which has '&' as the field delimiter, '#' as the record delimiter, and contains a header row:

Schema

{
      "field_delimiter" : "&",
      "record_delimiter" : "#"
}

Data

Item ID&Item Name&Item Color&Item Style&Quantity Purchased&Item Price&Total Price#55&bicycle&red&boys&1&100.00&100.00#88&toy boat&pink&&1&15.10&15.10#105&soap&&&1&0.99&0.99