Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save R-ohit-B-isht/c62f70b897a91c12c0946a81644ebb8d to your computer and use it in GitHub Desktop.
Save R-ohit-B-isht/c62f70b897a91c12c0946a81644ebb8d to your computer and use it in GitHub Desktop.

Playbook: Import Data from Excel Files into DynamoDB

Overview

This playbook will guide you through the process of importing data from Excel files into DynamoDB using an intermediary conversion to JSON format.

What’s Needed From User

  • Excel files containing the data to be imported.
  • AWS DynamoDB table details (table name, region).

Procedure

  1. Ask User for the Excel Data:

    • Request users to provide the Excel files containing the data to be imported into DynamoDB.
    • Review the structure of the Excel files and ensure that they contain the necessary data to be imported into DynamoDB.
  2. Convert Excel Data to JSON:

    • Install pandas and openpyxl libraries if not already installed:

      pip install pandas openpyxl
    • Create a Python script to read the Excel files and convert the data to JSON format.

  3. Verify JSON Data:

    • Review the generated JSON data to ensure that it accurately represents the data from the Excel files.
    • Verify that the JSON data is well-formatted and does not contain any errors or inconsistencies.
  4. Start all the Docker Containers:

    • Start the Docker containers for the services that are required for the import process.
    • Ensure that the Docker containers are running and accessible before proceeding with the import.
  5. Import JSON Data into DynamoDB:

    • Use the aws dynamodb batch-write-item command to import the JSON data into the DynamoDB table:

      aws dynamodb batch-write-item --request-items file://data.json --region <region>
      • Replace data.json with the path to your JSON file containing the data to be imported.
      • Replace <region> with the AWS region where your DynamoDB table is located.
  6. Verify Data Import:

    • Check the DynamoDB table to verify that the data has been successfully imported.
    • Verify that the data in DynamoDB matches the data from the Excel files.
  7. Clean Up:

    • Delete any temporary files or resources created during the import process.
    • Ensure that sensitive data is handled securely and not left exposed.
  8. Documentation:

    • Document the entire import process, including any tools or scripts used for conversion.
    • Include instructions for re-importing data in case of any issues or updates.
    • Document any considerations or limitations related to the import process.

Advice and Pointers

  • Test the data conversion process with a small subset of data before importing the entire dataset.
  • Handle any errors or inconsistencies in the Excel data during the conversion process.
  • Monitor the import process to ensure that it completes successfully and without errors.
  • Follow best practices for data handling and security to protect sensitive information.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment