Skip to content
v2.275.0

CsvOptions Struct ​

The options for imported source files in CSV format.

Example ​

ts
import * as cdk from 'aws-cdk-lib';
import * as s3 from 'aws-cdk-lib/aws-s3';

const app = new cdk.App();
const stack = new cdk.Stack(app, 'Stack');

declare const bucket: s3.IBucket;

new dynamodb.Table(stack, 'Table', {
  partitionKey: {
    name: 'id',
    type: dynamodb.AttributeType.STRING,
  },
  importSource: {
    compressionType: dynamodb.InputCompressionType.GZIP,
    inputFormat: dynamodb.InputFormat.csv({
      delimiter: ',',
      headerList: ['id', 'name'],
    }),
    bucket,
    keyPrefix: 'prefix',
  },
});

Properties ​

delimiteroptionalstringdelimiteroptionalstrdelimiteroptionalStringDelimiteroptionalstringDelimiteroptional*string#
The delimiter used for separating items in the CSV file being imported.

Default: use comma as a delimiter.

Valid delimiters are as follows:

  • comma (,)
  • tab (\t)
  • colon (:)
  • semicolon (;)
  • pipe (|)
  • space ()
headerListoptionalstring[]header_listoptionaltyping.List[str]headerListoptionalList<String>HeaderListoptionalstring[]HeaderListoptional*[]*string#
List of the headers used to specify a common header for all source CSV files being imported.

Default: the first line of the CSV file is treated as the header

NOTE: If this field is specified then the first line of each CSV file is treated as data instead of the header. If this field is not specified the first line of each CSV file is treated as the header.