Actually i "just" needed a list of all countries with their area code and a column to know if its landline or mobile. This way i could use it for asterisk to know if calling landline or mobile (thus selecting different routes). Googling for area-code lists on the web takes you to lists like this one which are quite nice but not mentioning mobile destinations. But there is a neat list available at SIL's website. Copied it over to LibreOffice Calc and saved it as CSV. Nearly perfect, just that all lines for mobile numbers have mostly more than one number for mobile...


"9370, 9379","Afghanistan","Mobile"
"35538, 35568, 35569","Albania","Mobile"
"2131, 21361, 2137","Algeria","Mobile"
"684","American Samoa","Landline"
"24491, 24492, 24495","Angola","Mobile"
"1268","Antigua & Barbuda","Landline"
"1268404, 1268406,1268409, 1268464, 126880","Antigua & Barbuda","Mobile"
"3747, 3749","Armenia","Mobile"
"6114, 6115, 6116, 6117, 6118, 6119, 614, 615, 6171","Australia","Mobile"

The goal is to have each prefix on one line, stating the country and whether its landline or mobile. Since i didn't know how to solve this, i asked on freenode irc network and got directed to #awk channel where i got a perfect answer:

< yitz_> $  awk -F', ?' '{for (i=1;i<=(NF-2);i++){gsub(/"/,"",$i);printf("\"%s\",%s,%s\n",$i,$(NF-1),$(NF))}}' <<< '"6114, 6115, 6116, 6117, 6118, 6119, 614, 615, 6171","Australia","Mobile"'
"97149",United Arab Emirates,Mobile
"97150",United Arab Emirates,Mobile
"97167",United Arab Emirates,Mobile
"97168",United Arab Emirates,Mobile
"97169",United Arab Emirates,Mobile
"97179",United Arab Emirates,Mobile

Wunderful :)

I should note:

< yitz_> Make sure to note it's flaky and prone to errors

< yitz_> awk gets the job done so long as this doesn't escape commas or have variable format

< yitz_> So long as the input rigidly follows that input format


After parsing the whole file i noticed, there is a leading comma after the last prefix of greece and hungary, so i just manually removed those two unneeded lines.

The complete csv file can be grabbed here.