Skip to content

Commit

Permalink
improve parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
martinlindhe committed Oct 16, 2015
1 parent 253178c commit ea70f4e
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 17 deletions.
13 changes: 8 additions & 5 deletions data/calling_codes.csv
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ code,country
355,Albania
213,Algeria
1684,"American Samoa"
NorthAmericanNumberingPlan,"American Samoa"
376,Andorra
244,Angola
1264,Anguilla
Expand Down Expand Up @@ -77,7 +76,8 @@ NorthAmericanNumberingPlan,"American Samoa"
593,Ecuador
20,Egypt
503,"El Salvador"
"8812,8813","Ellipso (Mobile Satellite service)"
8812,"Ellipso (Mobile Satellite service)"
8813,"Ellipso (Mobile Satellite service)"
88213,"EMSAT (Mobile Satellite service)"
240,"Equatorial Guinea"
291,Eritrea
Expand All @@ -98,7 +98,8 @@ NorthAmericanNumberingPlan,"American Samoa"
233,Ghana
350,Gibraltar
881,"Global Mobile Satellite System (GMSS)"
"8818,8819","Globalstar (Mobile Satellite Service)"
8818,"Globalstar (Mobile Satellite Service)"
8819,"Globalstar (Mobile Satellite Service)"
30,Greece
299,Greenland
1473,Grenada
Expand All @@ -114,7 +115,8 @@ NorthAmericanNumberingPlan,"American Samoa"
852,"Hong Kong"
36,Hungary
354,Iceland
"8810,8811","ICO Global (Mobile Satellite Service)"
8810,"ICO Global (Mobile Satellite Service)"
8811,"ICO Global (Mobile Satellite Service)"
91,India
62,Indonesia
870,"Inmarsat SNAC"
Expand All @@ -123,7 +125,8 @@ NorthAmericanNumberingPlan,"American Samoa"
98,Iran
964,Iraq
353,Ireland
"8816,8817","Iridium (Mobile Satellite service)"
8816,"Iridium (Mobile Satellite service)"
8817,"Iridium (Mobile Satellite service)"
44,"Isle of Man"
972,Israel
39,Italy
Expand Down
28 changes: 20 additions & 8 deletions data/calling_codes.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@
"country": "American Samoa",
"code": "1684"
},
{
"country": "American Samoa",
"code": "NorthAmericanNumberingPlan"
},
{
"country": "Andorra",
"code": "376"
Expand Down Expand Up @@ -313,7 +309,11 @@
},
{
"country": "Ellipso (Mobile Satellite service)",
"code": "8812,8813"
"code": "8812"
},
{
"country": "Ellipso (Mobile Satellite service)",
"code": "8813"
},
{
"country": "EMSAT (Mobile Satellite service)",
Expand Down Expand Up @@ -397,7 +397,11 @@
},
{
"country": "Globalstar (Mobile Satellite Service)",
"code": "8818,8819"
"code": "8818"
},
{
"country": "Globalstar (Mobile Satellite Service)",
"code": "8819"
},
{
"country": "Greece",
Expand Down Expand Up @@ -461,7 +465,11 @@
},
{
"country": "ICO Global (Mobile Satellite Service)",
"code": "8810,8811"
"code": "8810"
},
{
"country": "ICO Global (Mobile Satellite Service)",
"code": "8811"
},
{
"country": "India",
Expand Down Expand Up @@ -497,7 +505,11 @@
},
{
"country": "Iridium (Mobile Satellite service)",
"code": "8816,8817"
"code": "8816"
},
{
"country": "Iridium (Mobile Satellite service)",
"code": "8817"
},
{
"country": "Isle of Man",
Expand Down
18 changes: 14 additions & 4 deletions tools/update_calling_codes.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,21 @@ function extractLinks($s)
$code = str_replace(' ', '', $code);
$code = str_replace('+', '', $code);

$o = new \MartinLindhe\Data\CallingCodes\CallingCode;
$o->country = $country;
$o->code = $code;
$codes2 = explode(',', $code);

$list[] = $o;
foreach ($codes2 as $code2) {

if (!is_numeric($code2)) {
echo "Skipping ".$code2."\n";
continue;
}

$o = new \MartinLindhe\Data\CallingCodes\CallingCode;
$o->country = $country;
$o->code = $code2;

$list[] = $o;
}
}


Expand Down

0 comments on commit ea70f4e

Please sign in to comment.