ZIN02 / tools /json2jsonl.py
3v324v23's picture
update
922eb24
Raw
History Blame Contribute Delete
374 Bytes
import json, sys, lzma
data = json.loads(lzma.open(sys.argv[1],"rt").read())
lines = []
for x in data:
ss = json.dumps(x, ensure_ascii=False)
if len(ss) < 350:
# print(ss)
continue
lines.append((ss, len(ss)))
lines.sort(key=lambda x: x[1])
with open(sys.argv[2], "wt") as fout:
for line, n in lines: fout.write(line + "\n")