jashing commited on
Commit
332b209
·
1 Parent(s): ad228ad
Files changed (4) hide show
  1. energy_train.jsonl +0 -0
  2. parser.py +0 -53
  3. prepare.py +54 -0
  4. train.jsonl +0 -0
energy_train.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
parser.py DELETED
@@ -1,53 +0,0 @@
1
- import json
2
-
3
- # Specify the path to your JSON file
4
- file_path = 'train.jsonl'
5
-
6
- # Initialize empty lists to store the extracted values
7
- #timestamps = []
8
- targets = []
9
-
10
- # Open the JSON file and read it line by line
11
- with open(file_path, 'r') as file:
12
- for line in file:
13
- try:
14
- # Parse the JSON string in each line
15
- data = json.loads(line)
16
-
17
- # Extract the values of "timestamp" and "target" keys
18
- #timestamp = data.get("timestamp")
19
- target = data.get("target")
20
-
21
- if target is not None:
22
- #timestamps.append(timestamp)
23
- targets.append(target)
24
-
25
- except json.JSONDecodeError:
26
- print(f"Skipping invalid JSON: {line}")
27
-
28
- # Now, you have the extracted values in the "timestamps" and "targets" lists
29
- # You can use these lists as needed
30
- #print("Timestamps:", timestamps)
31
- print("Targets:", targets)
32
-
33
- hist_size = 10
34
- prd_size = 1
35
-
36
- while targets:
37
- # Get the first 5 elements and join them with spaces
38
- history = ' '.join(map(str, targets[:hist_size]))
39
- out = ' '.join(map(str,targets[hist_size:hist_size+prd_size]))
40
-
41
- # Construct the JSON string
42
- json_str = json.dumps({"color": out, "description": history})
43
-
44
- print (json_str)
45
- # Remove the first 6 elements from the float array
46
- targets = targets[1:]
47
- if len(targets) == hist_size:
48
- break
49
-
50
-
51
-
52
-
53
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
prepare.py ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+
3
+
4
+ def prepare():
5
+ file_path = 'energy_train.jsonl'
6
+ targets = []
7
+
8
+ # Open the JSON file and read it line by line
9
+ with open(file_path, 'r') as file:
10
+ for line in file:
11
+ #print (line)
12
+ try:
13
+ # Parse the JSON string in each line
14
+ data = json.loads(line)
15
+
16
+ # Extract the values of "timestamp" and "target" keys
17
+ #timestamp = data.get("timestamp")
18
+ target = data.get("target")
19
+
20
+ if target is not None:
21
+ #timestamps.append(timestamp)
22
+ targets.append(target)
23
+
24
+ except json.JSONDecodeError:
25
+ print(f"Skipping invalid JSON: {line}")
26
+
27
+ # Now, you have the extracted values in the "timestamps" and "targets" lists
28
+ # You can use these lists as needed
29
+ #print("Timestamps:", timestamps)
30
+ #print("Targets:", targets)
31
+
32
+ hist_size = 10
33
+ prd_size = 1
34
+
35
+ while targets:
36
+ # Get the first 5 elements and join them with spaces
37
+ history = ' '.join(map(str, targets[:hist_size]))
38
+ out = ' '.join(map(str,targets[hist_size:hist_size+prd_size]))
39
+
40
+ # Construct the JSON string
41
+ json_str = json.dumps({"color": out, "description": history})
42
+
43
+ print (json_str)
44
+ # Remove the first 6 elements from the float array
45
+ targets = targets[1:]
46
+ if len(targets) == hist_size:
47
+ break
48
+
49
+
50
+ if __name__ == "__main__":
51
+ #import fire
52
+ #fire.Fire(prepare)
53
+ prepare()
54
+
train.jsonl DELETED
The diff for this file is too large to render. See raw diff