I'm currently undertaking my masters thesis and recording lots of data (through in-house software) which churn out files in .JSON format. Any ideas of coding a way to convert this data directly into either .CSV or .xslx files?
Would save me so much time copying and pasting!
Thanks in advance.

well, sample data will help
but general advice is to look at json module and csv module from standard library. there are also third-party packages that may help depending on data
Of course, my mistake.
I'll have a look on them, thank you.
I don't have the code from Pithy to get the data in this format (someone else wrote it) - but this is how the data comes out in .JSON :
Name "sanitycheck"
TransmissionMode "PE"
Channel1 "1"
Channel2 "1"
BaseGain "70"
Delay "0"
Range "6"
Freq "5"
Energy "400"
FilterStandard "2"
ResponsibleParty ""
Notes ""
CyclerCode "00000"
LastWaveform ""
Run? "Y"
run "sanitycheck_PE_1_1_70_0_6_5_400"
source "25.45.49.195"
_id 1519057922
dtus 0.012121212121212121
amp
0 128
1 128
2 128
3 128
4 128
5 128
6 128
7 128
8 128
9 128
10 128
11 128
12 128
13 128
14 128
15 128
16 128
17 128
18 128
19 128
20 128
21 128
22 128
23 128
24 128
25 128
26 128
27 128
28 128
29 128
30 128
31 128
32 128
33 128
34 128
35 128
36 128
37 128
38 128
39 128
40 128
41 128
42 128
43 126
44 130
45 114
46 116
47 95
48 95
49 0
50 0
51 255
52 0
53 0
54 0
55 41
56 136
57 112
58 124
59 122
60 121
61 118
62 118
63 118
64 119
65 119
66 119
67 119
68 119
69 119
70 119
71 119
72 119
73 119
74 119
75 119
76 119
77 119
78 119
79 119
80 119
81 118
82 118
83 114
84 109
85 113
86 102
87 133
88 0
89 0
90 255
91 255
92 255
93 215
94 40
95 0
96 0
97 0
98 0
99 0
100 115
101 124
102 137
103 133
104 128
105 120
106 116
107 115
108 111
109 111
110 109
111 66
112 135
113 255
114 255
115 255
116 255
117 255
118 244
119 228
120 206
121 172
122 128
123 63
124 11
125 0
126 0
127 0
128 0
129 34
130 83
131 137
132 163
133 139
134 102
135 71
136 54
137 54
138 72
139 107
140 163
141 208
142 239
143 247
144 224
145 181
146 141
147 105
148 75
149 58
150 46
151 41
152 41
153 45
154 53
155 69
156 86
157 104
158 120
159 135
160 145
161 152
162 150
163 147
164 142
165 140
166 140
167 140
168 143
169 149
170 155
171 162
172 167
173 168
174 161
175 152
176 136
177 121
178 107
179 90
180 80
181 76
182 76
183 79
184 86
185 94
186 107
187 117
188 124
189 131
190 136
191 136
192 135
193 134
194 132
195 131
196 132
197 134
198 137
199 145
200 153
201 162
202 169
203 168
204 158
205 144
206 128
207 105
208 89
209 77
210 70
211 70
212 73
213 81
214 98
215 115
216 131
217 148
218 161
219 169
220 173
221 170
222 164
223 155
224 146
225 137
226 125
227 117
228 111
229 106
230 101
231 100
232 101
233 104
234 105
235 109
236 114
237 116
238 120
239 121
240 122
241 125
242 128
243 130
244 133
245 139
246 144
247 149
248 154
249 154
250 154
251 147
252 140
253 132
254 121
255 114
256 109
257 108
258 108
259 109
260 114
261 119
262 128
263 133
264 136
265 137
266 134
267 131
268 128
269 124
270 123
271 124
272 128
273 131
274 134
275 137
276 141
277 140
278 136
279 130
280 123
281 116
282 105
283 100
284 95
285 90
286 88
287 86
288 87
289 90
290 94
291 100
292 108
293 115
294 123
295 132
296 138
297 142
298 145
299 146
300 147
301 148
302 149
303 151
304 154
305 156
306 159
307 162
308 163
309 161
310 158
311 153
312 148
313 143
314 138
315 135
316 132
317 130
318 130
319 132
320 133
321 134
322 134
323 132
324 130
325 125
326 120
327 115
328 109
329 104
330 99
331 96
332 94
333 94
334 94
335 96
336 99
337 103
338 107
339 109
340 113
341 116
342 119
343 121
344 122
345 125
346 128
347 128
348 134
349 137
350 139
351 141
352 144
353 142
354 142
355 140
356 136
357 134
358 131
359 128
360 128
361 128
362 128
363 128
364 128
365 130
366 132
367 133
368 133
369 133
370 134
371 133
372 133
373 131
374 128
375 128
376 128
377 124
378 123
379 123
380 123
381 124
382 125
383 125
384 126
385 128
386 128
387 125
388 124
389 124
390 124
391 122
392 123
393 124
394 126
395 128
396 131
397 132
398 133
399 134
400 133
401 132
402 130
403 128
404 128
405 125
406 125
407 126
408 125
409 125
410 126
411 128
412 128
413 125
414 125
415 125
416 125
417 126
418 125
419 128
420 128
421 128
422 130
423 130
424 131
425 132
426 131
427 130
428 131
429 130
430 128
431 128
432 128
433 126
434 125
435 123
436 122
437 122
438 122
439 121
440 121
441 122
442 125
443 128
444 128
445 128
446 128
447 128
448 128
449 128
450 128
451 128
452 128
453 128
454 128
455 130
456 131
457 131
458 131
459 129
460 128
461 128
462 125
463 125
464 124
465 124
466 124
467 125
468 126
469 128
470 128
471 128
472 129
473 130
474 132
475 132
476 132
477 134
478 135
479 136
480 138
481 138
482 138
483 139
484 138
485 138
486 137
487 137
488 137
489 137
490 137
491 135
492 135
493 134
494 131
The idea is then to plot this data on a simple x-y graph on MATLAB (via excel through a lot of copy and pasting at the moment).
I don't think it is
json syntax, although there appears to be a collection of key/value pairs and a ordered list of values.
As mention it's not json,but more a key/value kind of data.
Then can write a example that fit's this data fine which is a dictionary.
d = {}
with open('2.txt') as f:
for line in f:
line = line.split()
if line == ['amp']:
d['amp'] = None
else:
d[line[0]] = line[1].replace('"', '')
A look at some data in dictionary,bye slicing out some values.
>>> import itertools
>>> dict(itertools.islice(d.items(), 0, 8))
{'BaseGain': '70',
'Channel1': '1',
'Channel2': '1',
'Delay': '0',
'Freq': '5',
'Name': 'sanitycheck',
'Range': '6',
'TransmissionMode': 'PE'}
Quote:The idea is then to plot this data on a simple x-y graph on MATLAB (via excel through a lot of copy and pasting at the moment).
Python has strong tools for this,that's can replace MATLAB and Excel.
Here a quick demo with plot of some of your data(
islice(d.items(), 60, 80)
) using
Matplotlib and
Jupyter Notebook.
Also look at
Pandas that can do same stuff as Excel,
and also easy to transport to Excel
df.read_excel()
and
df.to_excel()
.
![[Image: YzFDWu.jpg]](https://imagizer.imageshack.com/v2/640x480q90/924/YzFDWu.jpg)