Write a Python script that reads a CSV file containing product data (name, price, quantity) and uploads it to an Amazon DynamoDB table. Use Boto3 library to interact with DynamoDB and ensure proper error handling.
PLAINFORMAT
import csv
import boto3
from botocore.exceptions import ClientError

def read_csv_and_upload_to_dynamodb(file_path, table_name):
    # Initialize the DynamoDB client
    dynamodb = boto3.resource('dynamodb')
    
    try:
        # Get the specified table
        table = dynamodb.Table(table_name)
        
        # Open the CSV file and read its contents
        with open(file_path, 'r') as csvfile:
            reader = csv.DictReader(csvfile)
            
            for row in reader:
                # Extract the product data from the current row
                name = row['name']
                price = float(row['price'])
                quantity = int(row['quantity'])

                # Upload the product data to the DynamoDB table
                response = table.put_item(
                    Item={
                        'name': name,
                        'price': price,
                        'quantity': quantity
                    }
                )
                
                print(f"Uploaded item: {name}, {price}, {quantity}")
                
    except FileNotFoundError:
        print(f"The file '{file_path}' was not found.")
    except KeyError as e:
        print(f"Missing column in CSV file: {e}")
    except ClientError as e:
        print(f"An error occurred while uploading data to DynamoDB: {e}")

if __name__ == "__main__":
    csv_file_path = "path/to/your/csv/file.csv"
    dynamodb_table_name = "YourDynamoDBTableName"
    
    read_csv_and_upload_to_dynamodb(csv_file_path, dynamodb_table_name)