-
Notifications
You must be signed in to change notification settings - Fork 0
/
dabJsonify.py
executable file
·36 lines (28 loc) · 1.1 KB
/
dabJsonify.py
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
33
34
35
36
#! /usr/bin/python
import os
import json
import math
import argparse
def is_nan(x):
return isinstance(x, float) and math.isnan(x)
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Jsonify dabCollect.py RAW file')
parser.add_argument('-i', '--input', help='Input file', required=True)
parser.add_argument('-o', '--output', help='Output file', required=True)
cli_args = parser.parse_args()
print "Processing %s file to %s" % (cli_args.input, cli_args.output)
markers = []
with open(cli_args.input, 'r') as infile:
for line in infile:
j_content = json.loads(line)
valid = True
for attribute, value in j_content.iteritems():
#print "%s - |%s|" % (attribute, value)
if is_nan(value):
valid = False
print 'Can not process record : %s' % (j_content)
if valid:
markers.append(j_content)
with open(cli_args.output, 'w') as outfile:
json.dump(markers, outfile, allow_nan=False)
print "Done."