'How to get DynamoDb items given a CSV file with partition keys and sorting keys in AWS lambda (Python)

Hi I need to get all items from a DynamoDB table from a given CSV file of partition keys and sort keys in AWS lambda. For example if the CSV file is structured as:

PK            SK
example_1     example_1!
example_2     example_2!
example_3     example_3!

I need to get those specific items from the DynamoDB table. I have tried running this piece of code but with no success.

response = table.batch_get_item(
        RequestItems = {
            table:
                {'Keys': [{'PK': {'S': PK}} for data['PK'] in data]
            }
        }
    )
    result = response
    print(result)


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source