-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathleer.js
More file actions
31 lines (26 loc) · 888 Bytes
/
leer.js
File metadata and controls
31 lines (26 loc) · 888 Bytes
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
var request = require('request');
var S10 = require('s10');
var fs = require('fs');
const suffix = "US";
const prefix = "UH"
const cantidad = []
function reader() {
let americanos = []
file = fs.readFileSync('laia.json');
shipments = JSON.parse(file)
shipments.forEach(element => {
cantidad.push(element)
if (typeof element.idInternacional !== 'undefined' && element.idInternacional) {
//do stuff if query is defined and not null
if (element.idInternacional.slice(-2) === suffix && element.idInternacional.slice(0, 2) === prefix) {
americanos.push(element)
}
}
});
fs.writeFileSync("laia.json", JSON.stringify(americanos), { flag: 'a+' })
for (let index = 0; index < cantidad.length; index++) {
const element = cantidad[index];
console.log(index)
}
}
reader()