Import: CSV

Creates a data contract by inferring the schema (column names and types) from a CSV file.

{/* AUTOGENERATED EXAMPLE: do not edit by hand; regenerate with the update script. */}

Given this orders.csv:

order_id,order_timestamp,customer_id,order_total,status
ORD-1001,2024-01-01T10:00:00Z,CUST-1,4999,delivered
ORD-1002,2024-01-02T11:30:00Z,CUST-2,2500,shipped
ORD-1003,2024-01-03T09:15:00Z,CUST-3,1299,pending

Run:

datacontract import csv --source orders.csv

to produce the data contract:

version: 1.0.0
kind: DataContract
apiVersion: v3.1.0
id: my-data-contract
name: My Data Contract
status: draft
servers:
- server: production
  type: local
  customProperties:
  - property: delimiter
    value: ','
  format: csv
  path: examples/imports/csv/orders.csv
schema:
- name: orders
  physicalType: table
  description: Generated model of examples/imports/csv/orders.csv
  logicalType: object
  physicalName: orders
  properties:
  - name: order_id
    physicalType: VARCHAR
    logicalType: string
    required: true
    unique: true
    examples:
    - ORD-1003
    - ORD-1001
    - ORD-1002
  - name: order_timestamp
    physicalType: VARCHAR
    logicalType: date
    required: true
# …

{/* END AUTOGENERATED EXAMPLE */}