-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
34 lines (30 loc) · 827 Bytes
/
index.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
import fs from 'fs';
import es from 'event-stream';
import { gunzip } from 'zlib';
const process = (base64Value => {
let bufferBase64 = Buffer.from(base64Value, 'base64');
gunzip(bufferBase64, (err, buffer) => {
if (err) {
console.error('An error occurred:', err);
process.exitCode = 1;
}
fs.appendFile('result_base64.csv', `${buffer.toString()}\n` , (err) => {
if(err)
throw err;
});
});
});
var s = fs.createReadStream('dump_1.json')
.pipe(es.split())
.pipe(es.mapSync(function(line){
let parsed = JSON.parse(line);
process(parsed.Item.compressed_value.B);
})
.on('error', function(err){
console.log('Error while reading file.', err);
})
.on('end', function(){
console.log('Read entire file.')
s.end();
})
);