-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathsimplify_json.php
More file actions
37 lines (32 loc) · 788 Bytes
/
simplify_json.php
File metadata and controls
37 lines (32 loc) · 788 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
28
29
30
31
32
33
34
35
36
37
<?php
$fileName = "";
foreach ($_SERVER['argv'] as $key => $value) {
if ($key == 0) {
continue;
}
if (file_exists($value)) {
$fileName = $value;
}
}
if ($fileName == "") {
die("Empty file");
}
$data = file_get_contents($fileName);
$data = rtrim(rtrim($data, "\n"), ",");
$data = "[" . $data . "]";
$jsonData = json_decode($data, true);
unset($data);
$data = [];
foreach ($jsonData as $row) {
$newRow = [];
foreach ($row as $key => $value) {
if ($key != "cellMinV" && $key != "cellMaxV") {
if (substr($key, 0, 1) == "c" && substr($key, -1) == "V") {
continue;
}
}
$newRow[$key] = $value;
}
$data[] = $newRow;
}
file_put_contents($fileName . "_2", json_encode($data));