-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New code: ITU-T E.164 #229
Comments
I swear I looked into this but couldn't find an easily scrapeable original source. Maybe I'm mixing this up with TLD (top-level domains). There will be some countries that have the same calling code (e.g. USA = +1, Canada = +1, etc.), but I think it's useful as a destination only code (also could be useful as an origin code when/where there is only one country result). |
Would have to decide how to handle the https://en.m.wikipedia.org/wiki/North_American_Numbering_Plan. A lot of small Caribbean states have a unique area code, like Dominica +1 767, but some have more, like Dominican Republic +1 809, 829, 849. So do they all get simply +1? Any way you slice it, it’s many to one, one to many, or many to many. |
I'm not sure about this one. The I don't have the bandwidth right now to deal with the many-to-one issue in a more principled way. I guess what I'm saying is that I don't have strong views and would be on board with whatever you two think is best. |
I would not suggest using the I think it's probably a fairly common thing for people to have data like...
and they'd like to do something like... data %>%
mutate(country = countrycode(international_code, 'ITU-T_E.164', 'country.name') to get...
of course, that example's never going to work because |
My take on the North American Numbering Plan is that it is a sub-international (E.164) numbering plan, so technically the international calling code (E.164) is "1" for all of the countries it encompasses. That doesn't ease the issue of E.164 being a one-to-many numbering system, but it does mean there's a technically correct way of creating a lookup for E.164 (e.g. I believe the E.164 code for Dominican Republic should be "1"). |
Here's a start... library(tabulizer)
library(dplyr)
library(countrycode)
extract_tables('https://www.itu.int/dms_pub/itu-t/opb/sp/T-SP-E.164D-11-2011-PDF-E.pdf',
pages = 3:9, output = "data.frame") %>%
bind_rows() %>%
as_tibble() %>%
rename(code = 1, country = 2) %>%
filter(!is.na(code)) %>%
filter(!country %in% c('Reserved', 'Spare code')) %>%
filter(!grepl('^Reserved', country)) %>%
filter(!grepl('^International', country)) %>%
mutate(country.name = countrycode(country, 'country.name', 'country.name', warn = FALSE)) %>%
filter(!is.na(country.name)) %>%
select(e.164 = code, country.name)
#> # A tibble: 228 x 2
#> e.164 country.name
#> <int> <chr>
#> 1 1 American Samoa
#> 2 1 Anguilla
#> 3 1 Antigua & Barbuda
#> 4 1 Bahamas
#> 5 1 Barbados
#> 6 1 Bermuda
#> 7 1 British Virgin Islands
#> 8 1 Canada
#> 9 1 Cayman Islands
#> 10 1 Dominica
#> # … with 218 more rows but it doesn't catch a few weird things, like "Greenland (Denmark)"... library(tabulizer)
library(dplyr)
library(countrycode)
extract_tables('https://www.itu.int/dms_pub/itu-t/opb/sp/T-SP-E.164D-11-2011-PDF-E.pdf',
pages = 3:9, output = "data.frame") %>%
bind_rows() %>%
as_tibble() %>%
rename(code = 1, country = 2) %>%
filter(!is.na(code)) %>%
filter(!country %in% c('Reserved', 'Spare code')) %>%
filter(!grepl('^Reserved', country)) %>%
filter(!grepl('^International', country)) %>%
mutate(country.name = countrycode(country, 'country.name', 'country.name', warn = FALSE)) %>%
filter(is.na(country.name))
#> # A tibble: 10 x 4
#> code country Note country.name
#> <int> <chr> <chr> <chr>
#> 1 246 Diego Garcia "" <NA>
#> 2 252 Somali Democratic Republic "" <NA>
#> 3 262 French Departments and Territories in the Indian Oc… "j" <NA>
#> 4 299 Greenland (Denmark) "" <NA>
#> 5 388 Group of countries, shared code "" <NA>
#> 6 870 Inmarsat SNAC "" <NA>
#> 7 878 Universal Personal Telecommunication Service (UPT) "e" <NA>
#> 8 881 Global Mobile Satellite System (GMSS), shared code "n" <NA>
#> 9 888 Telecommunications for Disaster Relief (TDR) "k" <NA>
#> 10 991 Trial of a proposed new international telecommunica… "" <NA> ... and it requires |
Here's a better version using the 2016 version of codes found here. Unfortunately, they only have PDF or DOCX versions... neither of which is ideal for our purposes.
|
Add ITU-T E.164 codes, better known as "country calling codes". There may be a lot of edge cases here, and I don't know how much demand there is for these codes, but it's a pretty common form of country code in the real world. Feel free to 👍 or 👎 this issue to express your views.
The text was updated successfully, but these errors were encountered: