forked from Hackfmi/FMI-Data
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparse_programs.js
More file actions
57 lines (48 loc) · 1.72 KB
/
parse_programs.js
File metadata and controls
57 lines (48 loc) · 1.72 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
var
wrench = require("wrench"),
fs = require("fs"),
cheerio = require("cheerio"),
parseHelper = require("./parse_programs_helper.js"),
$ = null,
rawDataFolder = "program-raw-data";
var matchFileName = function(currentFile, fileNameToMatch) {
return currentFile.match(fileNameToMatch);
};
var buildPathToFile = function(file) {
return [__dirname, rawDataFolder, file].join("/");
};
var testData = function($, allGroupsInGivenDay, label) {
console.log("----- TESTING ", label.toUpperCase(), " -----");
allGroupsInGivenDay.forEach(function(item) {
// console.log(item);
// var currentGroup = fixIndex(filterEmptyCells(extractTableData($(item))));
var currentGroup = parseHelper.extractTableData($, $(item));
console.log(currentGroup);
// var groupWithLabels = currentGroup.map(function(x) {
// return {
// "label" : getLabel(extractCellHtml(x.item)).trim(),
// "room" : getRoom(extractCellHtml(x.item)).trim(),
// "start" : getStartTime(x.item, x.index, 5),
// "end" : getEndTime(x.item, x.index, 5),
// "type" : getType(x.item)
// };
// });
// console.log(JSON.stringify(groupWithLabels, null, 4));
});
};
wrench.readdirRecursive(rawDataFolder, function(error, curFiles) {
if(!curFiles) {
return false;
}
curFiles = curFiles.filter(function(item) {
return matchFileName(item, "sheet001.htm");
});
curFiles.forEach(function(item) {
// console.log();
$ = cheerio.load(
fs.readFileSync(
buildPathToFile(item)));
var allRows = $("table tr");
testData($, parseHelper.monday(allRows), "monday");
});
});