Skip to content

Instantly share code, notes, and snippets.

@ashee
Created August 2, 2020 15:18
Show Gist options
  • Save ashee/c25519ae76a8cd19a81e6f698fb7ff26 to your computer and use it in GitHub Desktop.
Save ashee/c25519ae76a8cd19a81e6f698fb7ff26 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import dask.bag as db
import json
from boto3.dynamodb.types import TypeDeserializer
def load_json(data):
doc = json.loads(data)
items = doc['Items']
d = TypeDeserializer()
return {k: d.deserialize(v) for item in items for k, v in item.items()}
if __name__ == "__main__":
ddb_data_file = "data/*.json"
b = db.read_text(ddb_data_file).map(load_json)
print(b.take(1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment