-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgen_registrars.js
35 lines (30 loc) · 1.04 KB
/
gen_registrars.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 { parse } = require('csv-parse/sync');
const Countries = require('./country_codes.json');
const f = Fs.readFileSync('./Accredited-Registrars-202410084636.csv');
const records = parse(f, {
columns: true, // Treat the first line as headers
skip_empty_lines: true, // Skip empty lines
trim: true, // Trim whitespace from each field
bom: true,
});
// console.log(records);
const out = [];
// Process each record
for (let record of records) {
if (!record['Country/Territory'] && record['Registrar Name'] === "Butterfly Asset Management Pte. Ltd") {
// Special case because no country is listed.
record['Country/Territory'] = 'Singapore';
}
const code = Countries[record['Country/Territory']];
if (!code) {
throw new Error("No country code for " + JSON.stringify(record));
}
out.push([
record['Registrar Name'],
Number(record['IANA Number']),
record['Country/Territory'],
code,
]);
}
console.log(JSON.stringify(out, null, '\t'));