Amazon S3 import formats for DynamoDB - Amazon DynamoDB
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Amazon S3 import formats for DynamoDB

DynamoDB can import data in three formats: CSV, DynamoDB JSON, and Amazon Ion.

CSV

A file in CSV format consists of multiple items delimited by newlines. By default, DynamoDB interprets the first line of an import file as the header and expects columns to be delimited by commas. You can also define headers that will be applied, as long as they match the number of columns in the file. If you define headers explicitly, the first line of the file will be imported as values.

Note

When importing from CSV files, all columns other than the hash range and keys of your base table and secondary indexes are imported as DynamoDB strings.

Escaping double quotes

Any double quotes characters that exist in the CSV file must be escaped. If they are not escaped, such as in this following example, the import will fail:

id,value "123",Women's Full Lenth Dress

This same import will succeed if the quotes are escaped with two sets of double quotes:

id,value """123""",Women's Full Lenth Dress

Once the text has been properly escaped and imported, it will appear as it did in the original CSV file:

id,value "123",Women's Full Lenth Dress

DynamoDB Json

A file in DynamoDB JSON format can consist of multiple Item objects. Each individual object is in DynamoDB’s standard marshalled JSON format, and newlines are used as item delimiters. As an added feature, exports from point in time are supported as an import source by default.

Note

New lines are used as item delimiters for a file in DynamoDB JSON format and shouldn't be used within an item object.

[{ "Item": { "Authors": { "SS": ["Author1", "Author2"] }, "Dimensions": { "S": "8.5 x 11.0 x 1.5" }, "ISBN": { "S": "333-3333333333" }, "Id": { "N": "103" }, "InPublication": { "BOOL": false }, "PageCount": { "N": "600" }, "Price": { "N": "2000" }, "ProductCategory": { "S": "Book" }, "Title": { "S": "Book 103 Title" } } }]
Note

New lines are used as item delimiters for a file in DynamoDB JSON format and shouldn't be used within an item object.

[{ "Item": { "Authors": { "SS": ["Author1", "Author2"] }, "Dimensions": { "S": "8.5 x 11.0 x 1.5" }, "ISBN": { "S": "333-3333333333" }, "Id": { "N": "103" }, "InPublication": { "BOOL": false }, "PageCount": { "N": "600" }, "Price": { "N": "2000" }, "ProductCategory": { "S": "Book" }, "Title": { "S": "Book 103 Title" } } },{ "Item": { "Authors": { "SS": ["Author1", "Author2"] }, "Dimensions": { "S": "8.5 x 11.0 x 1.5" }, "ISBN": { "S": "444-444444444" }, "Id": { "N": "104" }, "InPublication": { "BOOL": false }, "PageCount": { "N": "600" }, "Price": { "N": "2000" }, "ProductCategory": { "S": "Book" }, "Title": { "S": "Book 104 Title" } } },{ "Item": { "Authors": { "SS": ["Author1", "Author2"] }, "Dimensions": { "S": "8.5 x 11.0 x 1.5" }, "ISBN": { "S": "555-5555555555" }, "Id": { "N": "105" }, "InPublication": { "BOOL": false }, "PageCount": { "N": "600" }, "Price": { "N": "2000" }, "ProductCategory": { "S": "Book" }, "Title": { "S": "Book 105 Title" } } }]

Amazon Ion

Amazon Ion is a richly-typed, self-describing, hierarchical data serialization format built to address rapid development, decoupling, and efficiency challenges faced every day while engineering large-scale, service-oriented architectures.

When you import data in Ion format, the Ion datatypes are mapped to DynamoDB datatypes in the new DynamoDB table.

S. No. Ion to DynamoDB datatype conversion B

1

Ion Data Type

DynamoDB Representation

2

string

String (s)

3

bool

Boolean (BOOL)

4

decimal

Number (N)

5

blob

Binary (B)

6

list (with type annotation $dynamodb_SS, $dynamodb_NS, or $dynamodb_BS)

Set (SS, NS, BS)

7

list

List

8

struct

Map

Items in an Ion file are delimited by newlines. Each line begins with an Ion version marker, followed by an item in Ion format.

Note

In the following example, we've formatted items from an Ion-formatted file on multiple lines to improve readability.

$ion_1_0 [ { Item:{ Authors:$dynamodb_SS::["Author1","Author2"], Dimensions:"8.5 x 11.0 x 1.5", ISBN:"333-3333333333", Id:103., InPublication:false, PageCount:6d2, Price:2d3, ProductCategory:"Book", Title:"Book 103 Title" } }, { Item:{ Authors:$dynamodb_SS::["Author1","Author2"], Dimensions:"8.5 x 11.0 x 1.5", ISBN:"444-4444444444", Id:104., InPublication:false, PageCount:6d2, Price:2d3, ProductCategory:"Book", Title:"Book 104 Title" } }, { Item:{ Authors:$dynamodb_SS::["Author1","Author2"], Dimensions:"8.5 x 11.0 x 1.5", ISBN:"555-5555555555", Id:105., InPublication:false, PageCount:6d2, Price:2d3, ProductCategory:"Book", Title:"Book 105 Title" } } ]