We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e0c414d commit d13fc06Copy full SHA for d13fc06
jl-to-json
@@ -0,0 +1,31 @@
1
+#!/usr/bin/env python
2
+"""
3
+simple jsonlines to json converted
4
+usage: jl-to-json foo.jl > foo.json
5
+
6
+License: GPLv3
7
+Author: Bernardas Ališauskas <[email protected]>
8
9
+import json
10
11
+import click
12
+from click import echo
13
14
15
+@click.command()
16
+@click.argument('file', type=click.File('r'))
17
+@click.argument('key', default='id')
18
+def main(file, key):
19
+ """
20
+ simple jsonlines to json converted
21
+ usage: jl-to-json foo.jl > foo.json
22
23
+ data = {}
24
+ for line in file:
25
+ d = json.loads(line)
26
+ data[d[key]] = d
27
+ echo(json.dumps(data, ensure_ascii=False))
28
29
30
+if __name__ == '__main__':
31
+ main()
0 commit comments