Skip to content

Commit ff0b014

Browse files
committed
fix(data): re-add continents
1 parent 95e3a0c commit ff0b014

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

generate.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import fs from "fs";
22
import path from "path";
33

44
import { parse as csvParse } from "csv-parse";
5+
// eslint-disable-next-line import/no-unresolved
6+
import { parse as csvParseSync } from "csv-parse/sync";
57
import unzipper from "unzipper";
68
import got from "got";
79
import { DateTime } from "luxon";
@@ -26,14 +28,18 @@ async function run() {
2628
AN: "Antarctica",
2729
};
2830

29-
const countriesParser = got
30-
.stream("https://download.geonames.org/export/dump/countryInfo.txt")
31-
.pipe(
32-
csvParse({
33-
delimiter: "\t",
34-
skipRecordsWithError: true,
35-
}),
36-
);
31+
const { body: countriesData } = await got(
32+
"https://download.geonames.org/export/dump/countryInfo.txt",
33+
);
34+
35+
const countriesDataValidCsv = countriesData
36+
.split("EquivalentFipsCode")[1]
37+
.trim();
38+
39+
const countriesParser = csvParseSync(countriesDataValidCsv, {
40+
delimiter: "\t",
41+
skipRecordsWithError: true,
42+
});
3743
const countries = {};
3844
const countriesToContinents = {};
3945

0 commit comments

Comments
 (0)