0

I have 10k json files and i would like to insert them to Dynamo-DB one by one i would love to get some help. Python (py)

In all the json files the data are stored in the same format:

{
"_id": {
    "$oid": "582ff456aeddbf0ddcae6f58"
},
"product_filter": {
    "_id": {
        "Data_gender": "Women",
        ...
        ...
    }
},
"Data": {
    "AddDate": 1476546994,
    "fashionType": "Core",
    "Date": 123320000,
    "year": "2016",
    "brandDetailsEntry": {
        "id": 6746,
        "name": "lov me Weaves"
    },
    "id": 13132337,
    }

1 Answer 1

1

This is the sample of my code what i am using

import boto3
import json
import decimal

dynamodb = boto3.resource('dynamodb')

table = dynamodb.Table('tshirts')
i=1
while i<20020:
    with open("data"+str(i)+".json") as json_file:
    x=json.load(json_file, parse_float = decimal.Decimal)
    # for j in x:
    #     product_filter = j['product_filter']
   print(x)
   data = table.put_item(
       Item={'product_filter': x})
   data.save()
   print i
i+=1

i named my json files from 1 to 2000**

Sign up to request clarification or add additional context in comments.

1 Comment

What is the problem? Have you resolved it yourself ? You should put your code and data in OP.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.