-
Notifications
You must be signed in to change notification settings - Fork 23
/
ETLFileHandler.js
55 lines (45 loc) · 1.29 KB
/
ETLFileHandler.js
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
var fs = require('fs');
var Papa = require('papaparse');
const BinaryFile = require('binary-file');
function inputFile(filepath, filename) {
var binFile = new BinaryFile(filepath + filename, 'r', true);
binFile.open();
binFile.close();
}
(async function() {
try {
await binFile.open();
await binFile.close();
} catch (err) {
console.log(`There was an error: ${err}`);
}
}) ();
function accessChunk(loc,len, bf) {
const data = bf.read(len, bf.seek(loc));
return data;
}
// function inputFile(filepath, filename) {
// var readStream = fs.createReadStream(filepath + filename);
//
// readStream.on('data', function(chunk) {
// data += chunk;
// }).on('end', function() {
// console.log(data);
// });
//
// }
//
// function accessChunk(loc, len) {
// // read buffer of loc length if loc < 65536
// // if loc > 65536 read loc/65536 chunks and then read buffer of loc % 65536 length
// // after buffer is done reading, create buffer of len length and read into it
// // extract from this buffer and return data
// if (loc < 65536) {
// const buffer = Buffer.alloc(loc);
// buffer.write();
// }
//
// }
function parse_csv_server(path) {
var data_set = Papa.parse(path, {header : true});
};