我正在使用lambda函数将csv文件存储到发电机dB中,但出现此错误:
调用时发生错误(ValidationException) BatchWriteItem操作:提供的键元素与 模式:ClientError
import boto3
s3=boto3.client('s3')
dynamodb=boto3.resource('dynamodb')
def csv_reader(event, context):
#print(event)
bucket= event['Records'][0]['s3']['bucket']['name']
key= event['Records'][0]['s3']['object']['key']
obj = s3.get_object(Bucket=bucket, Key=key)
rows= obj['Body'].read().split('\n')
table= dynamodb.Table('batchdata')
with table.batch_writer() as batch:
for row in rows:
batch.put_item(Item={
'id':row.split(',')[0],
'courses':row.split(',')[1],
'statusOne':row.split(',')[2],
'statusTwo':row.split(',')[3],
'stream':row.split(',')[4]
})