-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathjson2csv2.py
More file actions
27 lines (20 loc) · 718 Bytes
/
json2csv2.py
File metadata and controls
27 lines (20 loc) · 718 Bytes
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
import csv
import json
x = open('test.json')
x = json.load(x)
f = csv.writer(open("test.csv", "wb+"))
# Write CSV Header, If you dont need that, remove this line
f.writerow(["SENSOR", "RESOLUTION", "POWER", "NAME", "VERSION", "TYPE",
"MAXIMUM_RANGE","VENDOR","PROBE","ACCURACY", "TIMESTAMP",
"LUX", "EVENT_TIMESTAMP",])
for x in x:
f.writerow([x["SENSOR"]["RESOLUTION"],
x["SENSOR"]["POWER"],
x["SENSOR"]["NAME"],
x["SENSOR"][ "VERSION"],
x["SENSOR"]["TYPE"],
x["PROBE"],
x["ACCURACY"],
x["TIMESTAMP"],
x["LUX"],
x["EVENT_TIMESTAMP"]])