def populate_table(table, data_file, print_msg):
"""Method to populate a table with records stored in a dict loaded from a json file
Args:
table(api.aws.DynamoTable): the table to write to
data_json(dict): the data to write. Should be an array in an object named 'data'
Returns:
None
"""
with open(os.path.join(resource_filename("manage", "data"), data_file), 'rt') as df:
data = json.load(df)
if len(data["data"]) == 1:
# Assume this is a campaign file for now.
print(" - Example campaign loaded: https://<your_stack>/campaign.html?id={}".format(data["data"][0]["campaign_id"]))
for item in data["data"]:
table.put_item(item)
print(print_msg)
评论列表
文章目录