Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Paste for NDJSON documents
import sys
import json
import itertools
fnames = sys.argv[1:]
jsons = [(json.loads(i) for i in open(fname)) for fname in fnames]
def paste(iterables):
for docs in itertools.izip_longest(*iterables, fillvalue={}):
for other in docs[1:]:
yield docs[0]
for doc in paste(jsons):
print json.dumps(doc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.