Issue with the scotland.json file
thisismyuniquegithubusername opened this issue · comments
First of all, thank you for making such a useful and user friendly library available for free! This has already saved me hours of work and has made my code a lot less hack-y in its implementation of population databases. With that said, I noticed that the scotland.json file seems to be much more out-of-date when compared to other json files in the data folder (including those that were not updated in the latest (May 2020) commit). It is not only in a seemingly different format, but does not contain most of the data that I assume it should (for example, population). This has made it incompatible with some of this library's functions. This isn't a big deal, and I was able to fix it by rewriting the file in my install and including the information that I needed (primarily population data), I just wanted to let you know in-case you encounter a similar issue. I would be happy to share my rewritten file once I make sure it is compatible with functions that I have not had to use it with. Please let me know if I have made some mistake or am misunderstanding the issue and thanks again for this otherwise great library!
Current Scotland File:
{
"name": "Scotland",
"flag": "",
"geoJSON": {},
"ISO": {
"alpha2": "",
"alpha3": ""
},
"provinces": ["Aberdeen City", "Aberdeenshire", "Angus", "Argyll and Bute", "City of Edinburgh", "Clackmannanshire", "Dumfries and Galloway", "Dundee City", "East Ayrshire", "East Dunbartonshire", "East Lothian", "East Renfrewshire", "Eilean Siar (Western Isles)", "Falkirk", "Fife", "Glasgow City", "Highland", "Inverclyde", "Midlothian", "Moray", "North Ayrshire", "North Lanarkshire", "Orkney Islands", "Perth and Kinross", "Renfrewshire", "Shetland Islands", "South Ayrshire", "South Lanarkshire", "Stirling", "The Scottish Borders", "West Dunbartonshire", "West Lothian"],
"tld": [],
"wiki": "http://en.wikipedia.org/wiki/scotland"
}
Compatible File:
{"name":"Saudi Arabia","altSpellings":["SA","Kingdom of Saudi Arabia","Al-Mamlakah al-‘Arabiyyah as-Su‘ūdiyyah"],"area":2149690,"borders":["IRQ","JOR","KWT","OMN","QAT","ARE","YEM"],"callingCodes":["966"],"capital":"Riyadh","capital_latlng":[24.631969,46.715065],"currencies":["SAR"],"demonym":"Saudi Arabian","flag":"","geoJSON":{"type":"FeatureCollection","features":[{"type":"Feature","id":"SAU","properties":{"name":"Saudi Arabia"},"geometry":{"type":"Polygon","coordinates":[[[42.779332,16.347891],[42.649573,16.774635],[42.347989,17.075806],[42.270888,17.474722],[41.754382,17.833046],[41.221391,18.6716],[40.939341,19.486485],[40.247652,20.174635],[39.801685,20.338862],[39.139399,21.291905],[39.023696,21.986875],[39.066329,22.579656],[38.492772,23.688451],[38.02386,24.078686],[37.483635,24.285495],[37.154818,24.858483],[37.209491,25.084542],[36.931627,25.602959],[36.639604,25.826228],[36.249137,26.570136],[35.640182,27.37652],[35.130187,28.063352],[34.632336,28.058546],[34.787779,28.607427],[34.83222,28.957483],[34.956037,29.356555],[36.068941,29.197495],[36.501214,29.505254],[36.740528,29.865283],[37.503582,30.003776],[37.66812,30.338665],[37.998849,30.5085],[37.002166,31.508413],[39.004886,32.010217],[39.195468,32.161009],[40.399994,31.889992],[41.889981,31.190009],[44.709499,29.178891],[46.568713,29.099025],[47.459822,29.002519],[47.708851,28.526063],[48.416094,28.552004],[48.807595,27.689628],[49.299554,27.461218],[49.470914,27.109999],[50.152422,26.689663],[50.212935,26.277027],[50.113303,25.943972],[50.239859,25.60805],[50.527387,25.327808],[50.660557,24.999896],[50.810108,24.754743],[51.112415,24.556331],[51.389608,24.627386],[51.579519,24.245497],[51.617708,24.014219],[52.000733,23.001154],[55.006803,22.496948],[55.208341,22.70833],[55.666659,22.000001],[54.999982,19.999994],[52.00001,19.000003],[49.116672,18.616668],[48.183344,18.166669],[47.466695,17.116682],[47.000005,16.949999],[46.749994,17.283338],[46.366659,17.233315],[45.399999,17.333335],[45.216651,17.433329],[44.062613,17.410359],[43.791519,17.319977],[43.380794,17.579987],[43.115798,17.08844],[43.218375,16.66689],[42.779332,16.347891]]]}}]},"ISO":{"alpha2":"SA","alpha3":"SAU"},"languages":["ar"],"latlng":[25,45],"nativeName":"العربية السعودية","population":30770375,"provinces":["'Asir","Al Bahah","Al Hudud ash Shamaliyah","Al Jawf","Al Madinah","Al Qasim","Ar Riyad","Ash Sharqiyah (Eastern Province)","Ha'il","Jizan","Makkah","Najran","Tabuk"],"region":"Asia","subregion":"Western Asia","timezones":["UTC+03:00"],"tld":[".sa"],"translations":{"de":"Saudi-Arabien","es":"Arabia Saudí","fr":"Arabie Saoudite","ja":"サウジアラビア","it":"Arabia Saudita"},"wiki":"http://en.wikipedia.org/wiki/saudi_arabia"}
I just checked and the Scotland file does work with functions that pull from data that it includes despite it being formatted differently (I guess the formatting doesn't matter and just makes it look different - the structure is apparently the same). The solution, then, appears to be to add the missing keys with empty values to the json file so that it does not cause KeyErrors when functions search for data from keys that do not exist and then to fill in those empty keys with info from Wikipedia. Thanks!
I'm sorry to keep adding comments, but I found that the json files for a few more countries (I noticed both the virgin islands and wales) do not have population keys (as well as are missing lots of other info keys) either and wanted to point it out for whoever ends up fixing this problem (I'll make a pull request with the fixes if I have the time, but I probably won't for a while)