blob: 606e8cc2d317cd0392eb516f69024fb3f84b842c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# Fluent Bit / Pack utf-8 samples to JSON
# =======================================
import os
import json
import msgpack
def gen_json(f):
print f
with io.open(f, 'rb') as raw:
data = raw.read()
out_mp = f[:-4] + ".mp"
out_json = f[:-4] + ".json"
# Write messagepack
fmp = open(out_mp, 'w')
fmp.write(msgpack.packb(data))
fmp.close()
fjson = open(out_json, 'w')
fjson.write(json.dumps(data).encode('utf8'))
fjson.close()
for fn in os.listdir('.'):
if not os.path.isfile(fn):
continue
if fn.startswith('utf8_') and fn.endswith('.txt'):
gen_json(fn)
|