-
Notifications
You must be signed in to change notification settings - Fork 0
/
cut_google.js
36 lines (33 loc) · 1.34 KB
/
cut_google.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
const fs = require('fs')
const JSONStream = require('JSONStream');
const es = require('event-stream');
const stream = fs.createReadStream('Records.json', {encoding: 'utf8'})
stream
.pipe(JSONStream.parse('locations.*'))
.pipe(es.mapSync(function (data) {
delete data.locationMetadata;
delete data.activity;
delete data.wifiScan;
delete data.activeWifiScan;
delete data.heading;
delete data.serverTimestamp;
delete data.verticalAccuracy;
delete data.batteryCharging;
delete data.formFactor;
delete data.osLevel;
delete data.platform;
delete data.platformType;
delete data.deviceTag;
delete data.source;
delete data.inferredLocation;
delete data.deviceTimestamp;
data.timestampMs = data.timestampMs || new Date(data.timestamp).getTime()
if (data.timestampMs) data.timestampMs = data.timestampMs.toString()
delete data.timestamp;
return data;
}))
.pipe(es.filterSync(function (data) {
return data.timestampMs > 1622575510551 && data.latitudeE7 && data.longitudeE7;
}))
.pipe(JSONStream.stringify(open = '{"locations": [\n', sep = ',\n', close = '\n]}\n'))
.pipe(fs.createWriteStream('google.json'));