tlx/dynamodb/batch.py
def load_json_dump(file_name, table_name, primary_key=False):
    """ Loads a file consisting of newline seperated items, in which each item is
        a json row object (Such as a BigQuery dump).

        If `primary_key` is provided the field is added to each item with a unique id as the sole partition key.
        If not provided, the input data must contain the keys of the dynamodb.
    """
    table = get_ddb_table(table_name)

    with open(file_name, 'r') as f:
        items = [
            json.loads(line.replace('\n', ''), parse_int=Decimal, parse_float=Decimal)
            for line in f
        ]

    if primary_key:
        for i in items:
            i[primary_key] = get_dynamo_compatible_uuid()

    batch_write(table, items)
 Loads a file consisting of newline seperated items, in which each item is
        a json row object (Such as a BigQuery dump).

        If `primary_key` is provided the field is added to each item with a unique id as the sole partition key.
        If not provided, the input data must contain the keys of the dynamodb.
    
Loads a file consisting of newline seperated items, in which each item is
a json row object (Such as a BigQuery dump).

If `primary_key` is provided the field is added to each item with a unique id as the sole partition key.
If not provided, the input data must contain the keys of the dynamodb.
Loads a file consisting of newline seperated items in which each item is a json row object ( Such as a BigQuery dump ) . If ` primary_key ` is provided the field is added to each item with a unique id as the sole partition key . If not provided the input data must contain the keys of the dynamodb .
def load_json_dump(file_name, table_name, primary_key=False):
    table = get_ddb_table(table_name)
    with open(file_name, 'r') as f:
        items = [
            json.loads(line.replace('\n', ''), parse_int=Decimal, parse_float=Decimal)
            for line in f
        ]
    if primary_key:
        for i in items:
            i[primary_key] = get_dynamo_compatible_uuid()
    batch_write(table, items)
def load_json_dump ( file_name , table_name , primary_key = False ) : table = get_ddb_table ( table_name ) with open ( file_name , 'r' ) as f : items = [ json . loads ( line . replace ( '\n' , '' ) , parse_int = Decimal , parse_float = Decimal ) for line in f ] if primary_key : for i in items : i [ primary_key ] = get_dynamo_compatible_uuid ( ) batch_write ( table , items )
Loads a file consisting of newline seperated items, in which each item is
a json row object (Such as a BigQuery dump).
Loads a file consisting of newline seperated items in which each item is a json row object ( Such as a BigQuery dump ) .
""" Loads a file consisting of newline seperated items, in which each item is
        a json row object (Such as a BigQuery dump).

        If `primary_key` is provided the field is added to each item with a unique id as the sole partition key.
        If not provided, the input data must contain the keys of the dynamodb.
    """
file_name
table_name
primary_key