forked from SoapSeller/OpenPension
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMetaTable.js
More file actions
27 lines (24 loc) · 1.1 KB
/
MetaTable.js
File metadata and controls
27 lines (24 loc) · 1.1 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
exports.getMetaTable = function(){
var parsedLines = require('fs').readFileSync('mt_source.csv').toString().split("\n")
//TODO: trim all values
var metaTable = {
hebrewColumns: parsedLines.shift().split(",").slice(2,parsedLines[0].length),
englishColumns: parsedLines.shift().split(",").slice(2,parsedLines[0].length).map(function(c) { return c.replace(/\s/g, "_").toLowerCase(); }),
dataTypes: parsedLines.shift().split(",").slice(2,parsedLines[0].length),
measures: parsedLines.shift().split(",").slice(2,parsedLines[0].length),
instrumentTypes: parsedLines.map(function(l){return l.split(",")[0]}),
instrumentSubTypes : parsedLines.map(function(l){return l.split(",")[1]}),
dataMapping: parsedLines.map(function(l){ return l.split(",").slice(2,l.split(",").length) }),
columnMappingForRow: function(rowId){
var output = [];
for (var i = 0; i < this.dataMapping[rowId].length ; i++ ){
var rowValue = parseInt(this.dataMapping[rowId][i]);
if (!isNaN(rowValue)){
output[rowValue] = this.hebrewColumns[i];
}
}
return output;
}
}
return metaTable;
}