manumanoj0010 / countrydetails

A Python package for retrieving data from all the countries in the world 🌏. The package has been published in the PyPI index. Give a star if you like it ✨
https://pypi.org/project/Countrydetails/
MIT License
19 stars 15 forks source link

cannot get country-level data #13

Open daroczig opened 10 months ago

daroczig commented 10 months ago

First of all, thanks for this super cool data and wrapper package :bow:

All countries data works fine, but I'm facing issues when trying to access a single country, see e.g.

>>> from Countrydetails import country, countries
>>> country.country_details(country_name = 'India')
.../python3.11/site-packages/Countrydetails/data/countries
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".../python3.11/site-packages/Countrydetails/country.py", line 39, in __init__
    if country_info.get('name', None):
       ^^^^^^^^^^^^^^^^
AttributeError: 'list' object has no attribute 'get'

I'm on a case-sensitive file-system, if that might be an issue .. but I have no idea how country_info ended up as a list :thinking:

patrysma commented 7 months ago

Same here, when testing using examples from README

Numbers00 commented 6 months ago

At least from my end (tested on Ubuntu 22.04, it's the glob in line 30 in Countrydetails/country.py that's causing the issue.

country_files = [files for files in glob(data_files + '*.json')]

It seems to be getting data/countries.json instead of data/countries/countries.json. You can just prepend a / before *.json there to fix it, but I'm unsure if this works for all platforms.

abhibalani commented 3 months ago

The issue still persists. The above hack works on windows though but not getting the right country by Capitalized country name.

'India' doesn't work. 'india' works.

count = country.country_details('India')
india = count.countries.get('india') 

Wasted good amount to time because of this.