jackiekazil / data-wrangling

Code repository for Data Wrangling with Python (O'Reilly)
559 stars 564 forks source link

"How to import XML Data" on page 57 with Python 3.6.3. #11

Closed jcvdlugt closed 6 years ago

jcvdlugt commented 7 years ago

I try to run "How to import XML Data" on page 57 with Python 3.6.3. However I get the following errors: TypeError: unhashable type: 'dict_keys'.; TypeError: 'dict_keys' object does not support indexing. Unsuccessfully I have tried to write the code with a 'list' in Python 3.6.3. Can you please give me the code for Python 3.6.3.? Most appreciated ... Johannes

kjam commented 7 years ago

Hi Johannes,

For Python 3, you need to transform the dictionary keys to a list. So this should work:

lookup_key = list(item.attrib.keys())[0]

Let me know if that fixes your problem!

-kj

jcvdlugt commented 6 years ago

Hi Katharine,

Yes, this fixes the problem.

Thank you very much for your help!

The book that you have written about “Data Wrangling ...” is very helpful and easy to understand.

Best regards ... Johannes

From: Katharine [mailto:notifications@github.com] Sent: Tuesday, December 5, 2017 10:25 AM To: jackiekazil/data-wrangling data-wrangling@noreply.github.com Cc: Johannes van der Lugt jcvdlugt@wxs.nl; Author author@noreply.github.com Subject: Re: [jackiekazil/data-wrangling] "How to import XML Data" on page 57 with Python 3.6.3. (#11)

Hi Johannes,

For Python 3, you need to transform the dictionary keys to a list. So this should work:

lookup_key = list(item.attrib.keys())[0]

Let me know if that fixes your problem!

-kj

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jackiekazil/data-wrangling/issues/11#issuecomment-349337379 , or mute the thread https://github.com/notifications/unsubscribe-auth/AgfT9Uu_LioyZCCMg8ZRprfQa2spYG-_ks5s9WBAgaJpZM4Q1Dck . https://github.com/notifications/beacon/AgfT9Rc3ciL-j4E-_OQRakw7JPGiGIj2ks5s9WBAgaJpZM4Q1Dck.gif

kjam commented 6 years ago

Great to hear! Happy Wrangling! :hugs: