Skip to content

Instantly share code, notes, and snippets.

@mttchpmn
Created December 23, 2019 07:05
Show Gist options
  • Save mttchpmn/3448db8a7c1ae0c10586f8e87b4b9fb1 to your computer and use it in GitHub Desktop.
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
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