英文:
Import items to DynamoDB from S3, what is the correct ion format?
问题
我想从一个 ion 文件中导入许多项到 DynamoDB,官方文档中有一个导入单个项的示例。但如何一次导入多个项呢?
我已经尝试过:
$ion_1_0{
Item: [
{
pk:1d0,
sk:1d0,
c1: "sql",
},
{
pk:1d0,
sk:2d0,
c1: "mono",
}
]
}
$ion_1_0{
Item: {
pk:1d0,
sk:1d0,
c1: "sql",
},
Item: {
pk:1d0,
sk:2d0,
c1: "mono",
}
}
都失败了。
文档中提供了一个多项的 JSON 示例,但它甚至不是有效的 JSON。
我不想使用 BatchWriteItem API,因为它比从 S3 导入要昂贵得多。
请给我一个从一个 ion/json 文件导入多个项到 DynamoDB 的正确示例。
英文:
I want to import many items to DynamoDB from a ion file, there is an example of importing only one item in official document. But how to import many items at once ?
I have tried:
$ion_1_0{
Item: [
{
pk:1d0,
sk:1d0,
c1: "sql",
},
{
pk:1d0,
sk:2d0,
c1: "mono",
}
]
}
$ion_1_0{
Item: {
pk:1d0,
sk:1d0,
c1: "sql",
},
Item: {
pk:1d0,
sk:2d0,
c1: "mono",
}
}
All failed.
The document give an multi-items example in json format, but it is even not a valid json.
And i don not want to use BatchWriteItem api, because it's much more expensive than import from S3.
Please give me a correct example of importing many items to DynamoDB from one ion/json file.
答案1
得分: 1
对于ION JSON,您想要使用以下格式的每个项目一行:
$ion_1_0 {Item:{EVENT_TIMESTAMP:"2020-12-20T04:20:23Z",ENTITY_ID:"802-23-1107",payment_currency:"IDR",user_agent:"Opera/9.52.(Windows NT 6.1; bem-ZM) Presto/2.9.187 Version/11.00",ip_address:"113.58.110.83",billing_latitude:"35.2312",EVENT_LABEL:"0",billing_zip:"79057",merchant:"fraud_O'Reilly, Mohr and Purdy",customer_job:"Textile designer",billing_city:"Mclean",card_bin:"414388",order_price:"20.89",product_category:"home",ENTITY_TYPE:"customer",billing_street:"58878 Schultz Creek Suite 615",billing_state:"TX",customer_email:"jade70@hunter.info",billing_longitude:"-100.6008",LABEL_TIMESTAMP:"2020-12-20T04:20:23Z",phone:"1-542-721-3025-4654",customer_name:"Chad",EVENT_ID:"3222fbd2170e0bdab70dc9b776e62c5942"}}
$ion_1_0 {Item:{EVENT_TIMESTAMP:"2020-12-10T14:33:00Z",ENTITY_ID:"163-90-5960",payment_currency:"ALL",user_agent:"Mozilla/5.0 (Windows NT 6.0) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/28.0.867.0 Safari/535.1",ip_address:"32.246.84.199",billing_latitude:"33.455",EVENT_LABEL:"1",billing_zip:"71764",merchant:"fraud_Stehr, Jewess and Schimmel",customer_job:"Senior tax professional/tax inspector",billing_city:"Stephens",card_bin:"485905",order_price:"739.19",product_category:"misc_net",ENTITY_TYPE:"customer",billing_street:"98349 Stephanie Pines",billing_state:"AR",customer_email:"dfields@cross.com",billing_longitude:"-93.0214",LABEL_TIMESTAMP:"2020-12-10T14:33:00Z",phone:"1-536-840-6013",customer_name:"Brittany",EVENT_ID:"327d0d3cb76e4f3fd9ef033bfeef7de89a"}}
...
...
...
$ion_1_0 {Item:{EVENT_TIMESTAMP:"2020-12-31T12:29:53Z",ENTITY_ID:"270-12-5682",payment_currency:"BWP",user_agent:"Mozilla/5.0 (compatible; MSIE 5.0; Windows 98; Trident/4.0)",ip_address:"31.217.241.76",billing_latitude:"34.7483",EVENT_LABEL:"0",billing_zip:"72201",merchant:"fraud_Streich, Hansen and Veum",customer_job:"Volunteer coordinator",billing_city:"Little Rock",card_bin:"601129",order_price:"50.6",product_category:"gas_transport",ENTITY_TYPE:"customer",billing_street:"195 Nunez Plains Apt. 224",billing_state:"AR",customer_email:"nathan08@flores.com",billing_longitude:"-92.2819",LABEL_TIMESTAMP:"2020-12-31T12:29:53Z",phone:"1580658844",customer_name:"Deanna",EVENT_ID:"3257c6c1325d974c8dc13c6e9784392baa"}}
英文:
For ION JSON you want to use a line per item in the following format
$ion_1_0 {Item:{EVENT_TIMESTAMP:"2020-12-20T04:20:23Z",ENTITY_ID:"802-23-1107",payment_currency:"IDR",user_agent:"Opera/9.52.(Windows NT 6.1; bem-ZM) Presto/2.9.187 Version/11.00",ip_address:"113.58.110.83",billing_latitude:"35.2312",EVENT_LABEL:"0",billing_zip:"79057",merchant:"fraud_O'Reilly, Mohr and Purdy",customer_job:"Textile designer",billing_city:"Mclean",card_bin:"414388",order_price:"20.89",product_category:"home",ENTITY_TYPE:"customer",billing_street:"58878 Schultz Creek Suite 615",billing_state:"TX",customer_email:"jade70@hunter.info",billing_longitude:"-100.6008",LABEL_TIMESTAMP:"2020-12-20T04:20:23Z",phone:"1-542-721-3025-4654",customer_name:"Chad",EVENT_ID:"3222fbd2170e0bdab70dc9b776e62c5942"}}
$ion_1_0 {Item:{EVENT_TIMESTAMP:"2020-12-10T14:33:00Z",ENTITY_ID:"163-90-5960",payment_currency:"ALL",user_agent:"Mozilla/5.0 (Windows NT 6.0) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/28.0.867.0 Safari/535.1",ip_address:"32.246.84.199",billing_latitude:"33.455",EVENT_LABEL:"1",billing_zip:"71764",merchant:"fraud_Stehr, Jewess and Schimmel",customer_job:"Senior tax professional/tax inspector",billing_city:"Stephens",card_bin:"485905",order_price:"739.19",product_category:"misc_net",ENTITY_TYPE:"customer",billing_street:"98349 Stephanie Pines",billing_state:"AR",customer_email:"dfields@cross.com",billing_longitude:"-93.0214",LABEL_TIMESTAMP:"2020-12-10T14:33:00Z",phone:"1-536-840-6013",customer_name:"Brittany",EVENT_ID:"327d0d3cb76e4f3fd9ef033bfeef7de89a"}}
...
...
...
$ion_1_0 {Item:{EVENT_TIMESTAMP:"2020-12-31T12:29:53Z",ENTITY_ID:"270-12-5682",payment_currency:"BWP",user_agent:"Mozilla/5.0 (compatible; MSIE 5.0; Windows 98; Trident/4.0)",ip_address:"31.217.241.76",billing_latitude:"34.7483",EVENT_LABEL:"0",billing_zip:"72201",merchant:"fraud_Streich, Hansen and Veum",customer_job:"Volunteer coordinator",billing_city:"Little Rock",card_bin:"601129",order_price:"50.6",product_category:"gas_transport",ENTITY_TYPE:"customer",billing_street:"195 Nunez Plains Apt. 224",billing_state:"AR",customer_email:"nathan08@flores.com",billing_longitude:"-92.2819",LABEL_TIMESTAMP:"2020-12-31T12:29:53Z",phone:"1580658844",customer_name:"Deanna",EVENT_ID:"3257c6c1325d974c8dc13c6e9784392baa"}}
答案2
得分: 1
从AWS文档中:-
Ion文件中的项目由换行符分隔。每行以Ion版本标记开头,后跟以Ion格式表示的项目。
这是一个工作示例:-
$ion_1_0 {Item:{pk:2.,sk:2.,c1:"mono"}}
$ion_1_0 {Item:{pk:1.,sk:1.,c1:"sql"}}
如果导入失败,您可以随时在Cloudwatch日志中查看确切的错误消息。
希望这能帮助您。
英文:
From AWS doc:-
> Items in an Ion file are delimited by newlines. Each line begins with
> an Ion version marker, followed by an item in Ion format.
Here is the working example:-
$ion_1_0 {Item:{pk:2.,sk:2.,c1:"mono"}}
$ion_1_0 {Item:{pk:1.,sk:1.,c1:"sql"}}
In case of import failure, you can always check in Cloudwatch logs for the exact error message.
Hope this helps.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论