TransWikia.com

Extracting city names in the text form from the function CountryData

Mathematica Asked by Camillus on March 19, 2021

I was planning to create an array with all capital cities in Europe using the following command:

CountryData["Europe", "CapitalCity"]

But unfortunately, it returns all results in rectangular frames. How can I get rid of them and get a simple text?

2 Answers

You can use the functions CanonicalName and CommonName:

eucc = CountryData["Europe", "CapitalCity"]

enter image description here

CanonicalName @ eucc

enter image description here

CommonName @ eucc

enter image description here

You can also use EntityValue "Name" to get CommonName[eucc]:

EntityValue[eucc, "Name"] == CommonName[eucc]
True

Correct answer by kglr on March 19, 2021

Use EntityValue with the property "CanonicalName":

EntityValue[CountryData["Europe","CapitalCity"],"CanonicalName"]

{{"Tirana", "Tirana", "Albania"}, {"AndorraLaVella", "AndorraLaVella", "Andorra"}, {"Vienna", "Vienna", "Austria"}, {"Minsk", "Minsk", "Belarus"}, {"Brussels", "Brussels", "Belgium"}, {"Sarajevo", "FederacijaBosnaIHercegovina", "BosniaHerzegovina"}, {"Sofia", "SofijaGrad", "Bulgaria"}, {"Zagreb", "GradZagreb", "Croatia"}, {"Nicosia", "Nicosia", "Cyprus"}, {"Prague", "Prague", "CzechRepublic"}, {"Copenhagen", "Copenhagen", "Denmark"}, {"Tallinn", "Harju", "Estonia"}, {"Torshavn", "Stromo", "FaroeIslands"}, {"Helsinki", "Uusimaa", "Finland"}, {"Paris", "IleDeFrance", "France"}, {"Berlin", "Berlin", "Germany"}, {"Gibraltar", "Gibraltar", "Gibraltar"}, {"Athens", "Attiki", "Greece"}, {"SaintPeterPort", "SaintPeterPort", "Guernsey"}, {"Budapest", "Budapest", "Hungary"}, {"Reykjavik", "Hofudhborgarsvaedhi", "Iceland"}, {"Dublin", "Dublin", "Ireland"}, {"Douglas", "Douglas", "IsleOfMan"}, {"Rome", "Lazio", "Italy"}, {"SaintHelier", "SaintHelier", "Jersey"}, {"Pristina", "Pristina", "Kosovo"}, {"Riga", "Riga", "Latvia"}, {"Vaduz", "Vaduz", "Liechtenstein"}, {"Vilnius", "Vilniaus", "Lithuania"}, {"Luxemburg", "Luxembourg", "Luxembourg"}, {"Skopje", "Skopje", "Macedonia"}, {"Valletta", "Valletta", "Malta"}, {"Chisinau", "Chisinau", "Moldova"}, {"MonacoVille", "Monaco", "Monaco"}, {"Podgorica", "Podgorica", "Montenegro"}, {"Amsterdam", "NoordHolland", "Netherlands"}, {"Oslo", "Oslo", "Norway"}, {"Warsaw", "Mazowieckie", "Poland"}, {"Lisbon", "Lisboa", "Portugal"}, {"Bucharest", "Bucharest", "Romania"}, {"SanMarino", "SanMarino", "SanMarino"}, {"Belgrade", "CentralSerbia", "Serbia"}, {"Bratislava", "Bratislavsky", "Slovakia"}, {"Ljubljana", "Osrednjeslovenska", "Slovenia"}, {"Madrid", "Madrid", "Spain"}, {"Longyearbyen", "Svalbard", "Svalbard"}, {"Stockholm", "Stockholm", "Sweden"}, {"Bern", "Bern", "Switzerland"}, {"Kiev", "Kiev", "Ukraine"}, {"London", "GreaterLondon", "UnitedKingdom"}, {"VaticanCity", "VaticanCity", "VaticanCity"}}

Answered by Carl Woll on March 19, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP