Giter Club home page Giter Club logo

countryinfo's People

Contributors

20geomine avatar arslanhashmi avatar atifiu avatar dilettagoglia avatar fayasnoushad avatar hersche avatar jannikj avatar kaspersorensen avatar pcorpet avatar porimol avatar praneetshekhar avatar propegasus avatar sentinel-1 avatar sgonsal avatar sohansolo avatar squeaky-pl avatar voidus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

countryinfo's Issues

Add alpha3 code to alt spelling

Currently countries entered as alpha3 codes result in KeyErrors since the alt spelling includes only alpha2 codes. Appending alpha3 codes from ISO would solve this.

Feature request - Demonym in multiple languages

Hello :)

Congrats on this beautiful library that you created! I have a feature request, would it be possible to add demonyms in multiple languages?

Thank you :)

//edit//

i suppose this would require setting the 'demonym' class to 'dict' instead of 'str' in the countryinfo.py file and editing the json files,

Wikipedia has a rather complete list with i.e. french demonyms: https://en.wiktionary.org/wiki/Appendix:French_demonyms

I'd try to prepare an edit if someone can explain to me how to programmatically make the necessary changes to the hundreds of json files...

Issue with the scotland.json file

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"}

Missing country: Andorra

It currently appears that the data for Andorra is missing. For a complete global dataset it would be much appreciated if this was present.

Thank you!

Wales and Scotland json are not complet

Great Job for this library, It 's a country library complete, I use it with Django Rest Framework.

Two Element I modify to on library comportement.

  • The first is ordering the country by name because the first was monaco.
  • the second is Wales and scotland json file are not filled like others

but it a good lib. I hope you will have more stars

Not all countries are available in CountryInfo.all()

Hello

I can't found all countries in CountryInfo.
Here is the list of countries code I haven't found: AD, AQ, MM, BQ, CW, BV, AX, TC, VG, VI, UM, ME, PS

Is that possible to add this (some or all) this countries ? Even if there is not much information about them ...

Thank you in advance

Add capital coordinates?

Hi, thanks for the nice package! Would you be interested in an "enhancement" PR which adds the capital's coordinates (lat/lng), e.g. via a method .capital_latlng() or whatever you suggest as a suitable name? If you think this is helpful, I'm happy to create a PR.

Please add provinces of Scotland to UK file.

I realise it is a politically charged issue, but since Scotland is still legally a part of the United Kingdom, one would expect to find Scotland's provinces in the list of UK's provinces.

Alternatively, please add Scotland as a province in the UK file.

Encoding problem

'm trying to use countryinfo with django 2.2 to get the countries informations :
when I tried to get this :

country = 'Morocco' 
information = CountryInfo(country)

I get this error:
'charmap' codec can't decode byte 0x81 in position 49: character maps to <undefined>

Countryinfo package charmap error

Hi!

I tried to use countryinfo package to match a country to it's continent but am still getting a charmap error message.

from countryinfo import CountryInfo
country = CountryInfo('France')
country.region()

File "...\AppData\Local\Programs\Python\Python37\lib\encodings\cp1257.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0xa1 in position 47: character maps to

PyCharm console:

sys.getdefaultencoding()
'utf-8'

So, why does it complain about CP1257 encoding?

Jerusalem is not the captial of Israel

Jerusalem is illegally occupied by Israel, and isn't even technically part of Israel. It is an individual territory granted special status according to the UN.

Documentation enhancement

Hi,
Great package!
Good you mention which data sources you are using in the readme?
Also, perhaps for which year the data is valid (e.g. important for population, but also for changing borders, ...).
Thanks for the package!
Best
kst

.all() improvements

Semantically, .all() should not be a method of the CountryInfo object, since that one represents the information for a specific country.

Instead, it should probably be a global function. While we're at it, I'd also say it should return a list of CountryInfo objects. If a user wants to access a specific one, they can create a CountryInfo object, so fast access isn't a big issue, and it would hide the json structure from library users.

Implementation-wise, this would be easier after #40

Missing countries

Hey,

thanks for your work. I found that serbia is not existing in your project yet and therefore not found. Would be nice if this is included.

https://en.wikipedia.org/wiki/Serbia

If you would prefer a PR with a such json, let me know and i will take the time.

Way to use .borders() info?

I want to get the population of the bordering countries to my input, the .borders() method returns, I believe, the alpha3 ISO code for the bordering countries, but the library does not accept alpha3 ISO codes as input. Is there an easy way to convert between the ISO code and the country name? Or to output .borders() info in an input-able format? In the meantime, I am going to add the ISO codes to the altSpellings list which will make them input-able, but I would love an official, cleaner fix!

Cache outside of the CountryInfo object

Currently, all files are loaded every time a CountryInfo object is created. That's inefficient and should be changed.

Easiest would probably be to move the data loading part to a cached global function

Longitude of Serbia is wrong

The value of 'latlng' for Serbia is [44.1305021, 16.4284181], which is a point in Bosnia, close to the border to Croatia. From Google, the correct values should be 44.0165° N, 21.0059° E.

Not giving a country name returns Eritrea

> CountryInfo().name()
'eritrea'

Question is, what is good behaviour here? I'd argue that since a CountryInfo object represents information about a specific country, a constructor argument should be mandatory.

Probably easier to do #41 first, since right now, accessing .all() requires constructing an object.

Macau missing key 'capital_latlng'

I run into a key error while try to access capital_latlng from Macau.

CountryInfo('Macau').info()['capital_latlng']

Despite that there no capital city exist, a nan or empty string as return value, would be preferred..

Example does not work

This example does not work:

country = CountryInfo('SG') print(country.info())

KeyError: 'sg'

Czechia/Czech Republic

Hello,
Would it be possible to update the name for Czechia (formerly Czech Republic) as this is causing issues with other databases.

Thanks!

Could you clarify an intended way of validation?

I work with few databases, and I can't control the exact country name used.
Hence, I need to validate DB names vs names in your library.
For example: 'Polska' instead of 'Poland'

What I came up with is:

def isCountryNameValid(name: str) -> bool:
    rv = True
    try:
        c = CountryInfo(name)
        data = c.native_name()
    except KeyError:
        rv = False
    return rv

If you have something better in mind (and I couldn't figure that out) -- could you add to API documentation?
Otherwise, maybe you'd like to add it, or share your view and I could try implement if myself :)

Summertime in CH

Hello, nice lib!

I would like to show the diffrent times of the diffrent countrys in a chat..

while try out, i found that switzerland have timezone utc+1, which is kind of correct in general.. however, we have summertime, so this is not true at the moment (rather utc+2).

https://greenwichmeantime.com/time-zone/europe/switzerland/time/

not shure how to solve that in structure.. show the currently active or add it to the array? i let that up to you.. however, a method with a datetime-object of current datetime there would be very cool as well!

best regards

vinz

Serbia, using alternate spelling 'RS' will fail to create a valid CountryInfo object

I try to get the info() output from Serbia while I use iso alpha2 "RS" for the country name.

CountryInfo('RS').info()

The code fails with an key error for 'rs' While 'RS' is not in the altSpellings list.

File "..\countryinfo.py", line 133, in capital _capital = self.__countries[self.__country_name]['capital'] KeyError: 'rs'

Running this code for other countries using alpha2 will work.
CountryInfo('DE').info()

I'm not sure if the the constructor of CountryInfo should support the iso alpha2 name as well?

I tried than to switch to full country name and encountered a problem with country name Czechia. Your help is much appriceated.

BR Lama

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.