Created
December 23, 2019 07:05
-
-
Save mttchpmn/3448db8a7c1ae0c10586f8e87b4b9fb1 to your computer and use it in GitHub Desktop.
Converts the copied text of 'http://www.aip.net.nz/pdf/AD_1.3.pdf' into a usable aerodromes object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const readline = require("readline"); | |
const fs = require("fs"); | |
const reader = readline.createInterface({ | |
input: fs.createReadStream("./aerolist.txt"), | |
output: process.stdout, | |
console: false | |
}); | |
let index = 0; | |
let result = {}; | |
let placeholder = ""; | |
reader.on("line", line => { | |
if (index === 0) placeholder = line; | |
if (index === 1) { | |
const code = line.slice(0, 4); | |
result[code] = placeholder; | |
} | |
if (index === 2) { | |
index = 0; | |
return; | |
} | |
index++; | |
}); | |
reader.on("close", () => { | |
console.log("result :", result); | |
fs.writeFileSync("./result.json", result); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment