-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathread.js
44 lines (33 loc) · 786 Bytes
/
read.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
var fs = require('fs');
var _ = require('underscore')._;
var LineByLineReader = require('line-by-line')
var redis = require("redis")
var filename = './lexsub_context_embeddings'
var DB = 13
var client = redis.createClient(6369)
lr = new LineByLineReader(filename);
lr.on('error', function (err) {
//'err' contains error object
});
lr.on('line', function (line) {
lr.pause();
var list = line.split(" ")
var key = list[0]
list.splice(0, 1);
client.select(DB, function() {
client.set(key, list, function(err, replies) {
if (replies != "OK")
{
console.log(err)
console.log(replies)
process.exit(0)
}
lr.resume();
})
})
});
//
lr.on('end', function () {
console.log("done")
process.exit()
});