Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reading country-codes results in KeyError: 'UN Statistics M49 numeric codes' #122

Closed
Fak3 opened this issue Jan 12, 2017 · 3 comments
Closed
Assignees

Comments

@Fak3
Copy link

Fak3 commented Jan 12, 2017

Hi. Tried to use jsontableschema-pandas and got an error. I am not sure what is wrong here:

In [5]: data_url = 'http://data.okfn.org/data/core/country-codes/datapackage.json'

In [6]: storage = datapackage.push_datapackage(data_url, 'pandas')
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-6-e3838b8c6b1f> in <module>()
----> 1 storage = datapackage.push_datapackage(data_url, 'pandas')

/home/u1/.virtualenvs/pandas3/lib/python3.4/site-packages/datapackage/pushpull.py in push_datapackage(descriptor, backend, **backend_options)
     74     for table in storage.buckets:
     75         if table in datamap:
---> 76             storage.write(table, datamap[table])
     77     return storage
     78 

/home/u1/.virtualenvs/pandas3/lib/python3.4/site-packages/jsontableschema_pandas/storage.py in write(self, bucket, rows)
    136         # Prepare
    137         descriptor = self.describe(bucket)
--> 138         new_data_frame = mappers.descriptor_and_rows_to_dataframe(descriptor, rows)
    139 
    140         # Just set new DataFrame if current is empty

/home/u1/.virtualenvs/pandas3/lib/python3.4/site-packages/jsontableschema_pandas/mappers.py in descriptor_and_rows_to_dataframe(descriptor, rows)
     31     index_rows = []
     32     jtstypes_map = {}
---> 33     for row in rows:
     34         values = []
     35         index = None

/home/u1/.virtualenvs/pandas3/lib/python3.4/site-packages/datapackage/pushpull.py in values(schema, data)
     53         # TODO: review
     54         def values(schema, data):
---> 55             for item in data:
     56                 row = []
     57                 for field in schema['fields']:

/home/u1/.virtualenvs/pandas3/lib/python3.4/site-packages/datapackage/resource.py in _iter_from_tabulator(self, table, schema)
    325             if model is not None:
    326                 for field in model.fields:
--> 327                     value = keyed_row[field.name]
    328                     try:
    329                         keyed_row[field.name] = field.cast_value(value)

KeyError: 'UN Statistics M49 numeric codes'
@rufuspollock rufuspollock changed the title Reading core/country-codes results in KeyError: 'UN Statistics M49 numeric codes' Reading country-codes results in KeyError: 'UN Statistics M49 numeric codes' Jan 13, 2017
@roll roll self-assigned this Jan 13, 2017
@roll
Copy link
Member

roll commented Jan 13, 2017

$ goodtables datapackage http://data.okfn.org/data/core/country-codes/datapackage.json
DATASET
=======
{'error-count': 2, 'table-count': 1, 'time': 4.537, 'valid': False}

TABLE [1]
=========
{'datapackage': 'http://data.okfn.org/data/core/country-codes/datapackage.json',
 'error-count': 2,
 'headers': ['name',
             'official_name_en',
             'official_name_fr',
             'ISO3166-1-Alpha-2',
             'ISO3166-1-Alpha-3',
             'ISO3166-1-numeric',
             'ITU',
             'MARC',
             'WMO',
             'DS',
             'Dial',
             'FIFA',
             'FIPS',
             'GAUL',
             'IOC',
             'ISO4217-currency_alphabetic_code',
             'ISO4217-currency_country_name',
             'ISO4217-currency_minor_unit',
             'ISO4217-currency_name',
             'ISO4217-currency_numeric_code',
             'is_independent',
             'Capital',
             'Continent',
             'TLD',
             'Languages',
             'geonameid',
             'EDGAR'],
 'row-count': 252,
 'source': 'https://raw.github.com/datasets/country-codes/master/data/country-codes.csv',
 'time': 3.752,
 'valid': False}
---------
[-,6] [non-matching-header] Header in column 6 doesn't match field name UN Statistics M49 numeric codes
[-,26] [non-matching-header] Header in column 26 doesn't match field name Geoname ID

@roll roll added [0.25d] and removed (py) labels Jan 13, 2017
@Fak3
Copy link
Author

Fak3 commented Jan 16, 2017

Should the bug be moved to https://github.com/datasets/country-codes repo?

@roll
Copy link
Member

roll commented Jan 16, 2017

MOVED
datasets/country-codes#51

@roll roll closed this as completed Jan 16, 2017
@roll roll added duplicate and removed current labels Jan 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants