File tree Expand file tree Collapse file tree 1 file changed +14
-8
lines changed Expand file tree Collapse file tree 1 file changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ import fs from "fs";
2
2
import path from "path" ;
3
3
4
4
import { parse as csvParse } from "csv-parse" ;
5
+ // eslint-disable-next-line import/no-unresolved
6
+ import { parse as csvParseSync } from "csv-parse/sync" ;
5
7
import unzipper from "unzipper" ;
6
8
import got from "got" ;
7
9
import { DateTime } from "luxon" ;
@@ -26,14 +28,18 @@ async function run() {
26
28
AN : "Antarctica" ,
27
29
} ;
28
30
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
+ } ) ;
37
43
const countries = { } ;
38
44
const countriesToContinents = { } ;
39
45
You can’t perform that action at this time.
0 commit comments