airline-codes 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/publish.yml +8 -1
- package/README.md +3 -0
- package/airlines.dat +6064 -6064
- package/airlines.json +6063 -6063
- package/convert.js +17 -10
- package/normalize.js +43 -0
- package/package.json +2 -2
package/convert.js
CHANGED
|
@@ -5,15 +5,22 @@ var _ = require('lodash');
|
|
|
5
5
|
|
|
6
6
|
var columns = ['id', 'name', 'alias', 'iata', 'icao', 'callsign', 'country', 'active'];
|
|
7
7
|
|
|
8
|
-
var
|
|
9
|
-
var writeStream = fs.createWriteStream('airlines.json');
|
|
8
|
+
var content = fs.readFileSync('airlines.dat', 'utf8');
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
csv.parse(content, function(err, records) {
|
|
11
|
+
if (err) throw err;
|
|
12
|
+
|
|
13
|
+
var airlines = records.map(function(data) {
|
|
14
|
+
return _.zipObject(columns, data);
|
|
15
|
+
});
|
|
14
16
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
.
|
|
18
|
-
|
|
19
|
-
.
|
|
17
|
+
// Sort active airlines first so they take precedence over inactive ones
|
|
18
|
+
// when consumers look up by IATA/ICAO code
|
|
19
|
+
airlines = _.sortBy(airlines, function(a) { return a.active === 'Y' ? 0 : 1; });
|
|
20
|
+
|
|
21
|
+
var writeStream = fs.createWriteStream('airlines.json');
|
|
22
|
+
var jsonStream = JSONStream.stringify();
|
|
23
|
+
jsonStream.pipe(writeStream);
|
|
24
|
+
airlines.forEach(function(a) { jsonStream.write(a); });
|
|
25
|
+
jsonStream.end();
|
|
26
|
+
});
|
package/normalize.js
CHANGED
|
@@ -41,6 +41,44 @@ var ID_CORRECTIONS = {
|
|
|
41
41
|
'3386': { active: 'N' }, // Malmö Aviation (dup of above, same ICAO SCW)
|
|
42
42
|
'4264': { active: 'N' }, // Royal Nepal Airlines (defunct, replaced by Nepal Airlines)
|
|
43
43
|
'4560': { active: 'N' }, // Swissair (defunct, dup of Swiss Intl, same ICAO SWR)
|
|
44
|
+
// IATA code collision fixes - defunct airlines sharing code with active ones:
|
|
45
|
+
'595': { active: 'N' }, // Atlant-Soyuz Airlines (3G) - ceased 2011
|
|
46
|
+
'19862': { active: 'N' }, // AsiaCargo Express (3G) - rebranded/ceased 2020
|
|
47
|
+
'2051': { active: 'N' }, // DonbassAero (5D) - ceased 2013
|
|
48
|
+
'3432': { active: 'N' }, // Maxair (8M) - ceased 2005
|
|
49
|
+
'3570': { active: 'N' }, // Myanmar Airways International (8M) - duplicate entry (keep id 19846)
|
|
50
|
+
'1436': { active: 'N' }, // Bellview Airlines (B3) - ceased 2009
|
|
51
|
+
'543': { active: 'N' }, // Air Bangladesh (B9) - ceased 2005
|
|
52
|
+
'1411': { active: 'N' }, // British International Helicopters (BS) - ceased 2012
|
|
53
|
+
'3363': { active: 'N' }, // Macair Airlines (CC) - ceased 2009
|
|
54
|
+
'1881': { active: 'N' }, // Continental Airlines (CO) - merged into United 2012
|
|
55
|
+
'1883': { active: 'N' }, // Continental Express (CO) - defunct
|
|
56
|
+
'1615': { active: 'N' }, // Canadian Airlines (CP) - bankrupt 2001
|
|
57
|
+
'1860': { active: 'N' }, // Compass Airlines (CP) - ceased 2020
|
|
58
|
+
'1790': { active: 'N' }, // City Connexion Airlines (G3) - ceased ~2000
|
|
59
|
+
'116': { active: 'N' }, // Air Italy (I9) - liquidated 2020
|
|
60
|
+
'2855': { active: 'N' }, // Indigo/IBU (I9) - ceased 2004
|
|
61
|
+
'4188': { active: 'N' }, // Republic Express Airlines (RH) - ceased 2010
|
|
62
|
+
'4936': { active: 'N' }, // Tiger Airways (TR) - merged into Scoot 2017
|
|
63
|
+
'2439': { active: 'N' }, // Formosa Airlines (VY) - merged 1999
|
|
64
|
+
'5424': { active: 'N' }, // Western Airlines (WA) - merged into Delta 1987
|
|
65
|
+
'575': { active: 'N' }, // Air Exel (XT) - ceased 2005
|
|
66
|
+
'792': { active: 'N' }, // Access Air (ZA) - ceased 2001
|
|
67
|
+
'2883': { active: 'N' }, // Interavia Airlines (ZA) - ceased 2008
|
|
68
|
+
'220': { active: 'N' }, // Air Bourbon (ZB) - ceased 2004
|
|
69
|
+
'3532': { active: 'N' }, // Monarch Airlines (ZB) - collapsed 2017
|
|
70
|
+
'3743': { active: 'N' }, // Novair (1I) - bankrupt 2023
|
|
71
|
+
'3788': { active: 'N' }, // Onur Air (8Q) - bankrupt 2021
|
|
72
|
+
'5559': { active: 'N' }, // Maldivian Air Taxi (8Q) - merged into Trans Maldivian 2013
|
|
73
|
+
'1879': { active: 'N' }, // Contact Air (C3) - ceased 2012
|
|
74
|
+
'12997': { active: 'N' }, // QatXpress (C3) - defunct
|
|
75
|
+
'19861': { active: 'N' }, // Regent Airways (RX) - suspended 2020
|
|
76
|
+
'19676': { active: 'N' }, // Rainbow Air Polynesia (RX) - defunct
|
|
77
|
+
'4981': { active: 'N' }, // Trans Mediterranean Airlines (TL) - ceased 2014
|
|
78
|
+
'11850': { active: 'N' }, // Skyjet Airlines (UQ) - ceased 2009
|
|
79
|
+
// Wrong IATA codes in upstream data:
|
|
80
|
+
'4374': { iata: 'GQ' }, // Sky Express Greece - correct code is GQ not G3
|
|
81
|
+
'19849': { iata: 'GX' }, // Guangxi Beibu Gulf Airlines - correct code is GX not UQ
|
|
44
82
|
};
|
|
45
83
|
|
|
46
84
|
var columns = ['id', 'name', 'alias', 'iata', 'icao', 'callsign', 'country', 'active'];
|
|
@@ -56,6 +94,11 @@ csv.parse(content, function(err, records) {
|
|
|
56
94
|
var id = row[0];
|
|
57
95
|
var original = row.slice();
|
|
58
96
|
|
|
97
|
+
// Strip leading spaces from callsign (upstream data corruption)
|
|
98
|
+
if (row[5] && row[5][0] === ' ') {
|
|
99
|
+
row[5] = row[5].trim();
|
|
100
|
+
}
|
|
101
|
+
|
|
59
102
|
// Apply country name corrections
|
|
60
103
|
var countryIdx = 6;
|
|
61
104
|
if (COUNTRY_CORRECTIONS[row[countryIdx]]) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "airline-codes",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "Airline codes (IATA) and information pulled from OpenFlights.org.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"bugs": {
|
|
26
26
|
"url": "https://github.com/npow/airline-codes/issues"
|
|
27
27
|
},
|
|
28
|
-
"homepage": "https://github.com/
|
|
28
|
+
"homepage": "https://github.com/npow/airline-codes",
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"JSONStream": "^1.0.4",
|
|
31
31
|
"backbone": "^1.1.2",
|