Datasets:

Modalities:
Text
Formats:
json
Libraries:
Datasets
Dask
License:
kocoten1992 commited on
Commit
10cc034
1 Parent(s): 70fb3b6

feat: add join_dataset.py util file

Browse files
Files changed (2) hide show
  1. README.md +1 -15
  2. join_dataset.py +17 -0
README.md CHANGED
@@ -3,19 +3,5 @@ license: wtfpl
3
  ---
4
 
5
  # To join all training set files together
6
- Use this script https://stackoverflow.com/a/57422761, copied here for redundancy:
7
 
8
- ```python
9
- files=['my.json','files.json',...,'name.json']
10
-
11
- def merge_JsonFiles(filename):
12
- result = list()
13
- for f1 in filename:
14
- with open(f1, 'r') as infile:
15
- result.extend(json.load(infile))
16
-
17
- with open('counseling3.json', 'w') as output_file:
18
- json.dump(result, output_file)
19
-
20
- merge_JsonFiles(files)
21
- ```
 
3
  ---
4
 
5
  # To join all training set files together
6
+ run `python join_dataset.py` file, final result will be `join_dataset.json` file
7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
join_dataset.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import json
3
+
4
+ json_files = [];
5
+
6
+ for file in os.listdir():
7
+ if file.endswith('.json'):
8
+ json_files.append(file)
9
+
10
+ result = list()
11
+
12
+ for f1 in json_files:
13
+ with open(f1, 'r') as infile:
14
+ result.extend(json.load(infile))
15
+
16
+ with open('join_dataset.json', 'w') as output_file:
17
+ json.dump(result, output_file)