Working with other API specs

CSV Integration

Overview

Taxi provides CSV format support through model annotations, enabling:

  • CSV reading and writing with semantic types
  • Configurable delimiters, headers, and value handling
  • Column name mapping

Declaring CSV Models

Add the Csv annotation to models that represent CSV data:

import com.orbitalhq.formats.Csv

@Csv
model Person {
   firstName: FirstName inherits String
   lastName: LastName inherits String
   age: Age inherits Int
}

Configuration Options

The Csv annotation supports several configuration parameters:

import com.orbitalhq.formats.Csv

@Csv(
  delimiter = "|",
  nullValue = "NULL",
  firstRecordAsHeader = true,
  containsTrailingDelimiters = false,
  quoteChar = "\""
)
model Person {
   firstName: FirstName inherits String
   lastName: LastName inherits String
   age: Age inherits Int
}

Available Options

ParameterDescriptionDefault
delimiterCharacter separating fields,
firstRecordAsHeaderUse first record as column headerstrue
nullValueString to interpret as null
containsTrailingDelimitersWhether rows end with delimiterfalse
quoteCharCharacter for quoting fields"

Column Mapping

Default Mapping

By default, field names in the model are used to match CSV column names:

model Person {
   // Matches CSV column "firstName"
   firstName: FirstName inherits String
   
   // Matches CSV column "lastName" 
   lastName: LastName inherits String
}

Legacy Column References

Deprecated

Using the by column tag is deprecated. Field names in the model are now used to match columns.

For backward compatibility, explicit column mapping is supported but discouraged:

model Person {
  firstName: FirstName by column("fName")  // Maps to CSV column "fName"
}
Previous
SOAP
Next
XML