Skip to content

Quick way to concat/merge all files from directory? #2593

Answered by saulpw
bwiggs asked this question in Q&A
Discussion options

You must be logged in to vote

Here's a script (untested) that concatenates json files:

import sys
import json

objs = []
for fn in sys.argv[1:]:
    objs.append(json.loads(open(fn).read()))
json.dumps(objs)

If script is called "jsoncat.py" then you can do:

jsoncat.py *.json | vd

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@bwiggs
Comment options

Answer selected by bwiggs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants