-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathgetDataDump.js
More file actions
34 lines (32 loc) · 1020 Bytes
/
getDataDump.js
File metadata and controls
34 lines (32 loc) · 1020 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
/**
* Created by matt on 22.09.16.
*/
var fs = require('fs');
var DC = require('./dataSet_creator.js').DC;
var source = 'json/pokeDump_2_sorted.json';
var destination = 'arff/dataDump_50k_sorted.arff';
processDump(source, 0, 50);
/**
* take the data dump and add features to get an arff file
* @param _source json file to use
* @param from_line starting this line in the file
* @param number_lines finishing on this line in the file
*/
function processDump(_source, from_line, number_lines) {
var data;
try {
data = fs.readFileSync(_source, 'utf8');
} catch (err) {
console.log(err);
}
try {
var jsonData = JSON.parse(data);
} catch (err) {
console.log(err);
}
console.log('Read ' + jsonData.length + ' from file');
var data_less = jsonData.slice(from_line, from_line+number_lines);
console.log('Sliced to ' + data_less.length + ' entries');
DC.init("feature_config.json", false);
DC.storeArffFile(data_less, destination, false);
}