Skip to content

Commit

Permalink
fix(data): re-add continents
Browse files Browse the repository at this point in the history
  • Loading branch information
vvo committed Feb 21, 2022
1 parent 95e3a0c commit ff0b014
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import fs from "fs";
import path from "path";

import { parse as csvParse } from "csv-parse";
// eslint-disable-next-line import/no-unresolved
import { parse as csvParseSync } from "csv-parse/sync";
import unzipper from "unzipper";
import got from "got";
import { DateTime } from "luxon";
Expand All @@ -26,14 +28,18 @@ async function run() {
AN: "Antarctica",
};

const countriesParser = got
.stream("https://download.geonames.org/export/dump/countryInfo.txt")
.pipe(
csvParse({
delimiter: "\t",
skipRecordsWithError: true,
}),
);
const { body: countriesData } = await got(
"https://download.geonames.org/export/dump/countryInfo.txt",
);

const countriesDataValidCsv = countriesData
.split("EquivalentFipsCode")[1]
.trim();

const countriesParser = csvParseSync(countriesDataValidCsv, {
delimiter: "\t",
skipRecordsWithError: true,
});
const countries = {};
const countriesToContinents = {};

Expand Down

0 comments on commit ff0b014

Please sign in to comment.