0

I am trying to build up a network using Networkx library in python. Some of the node names are url links. For example, one of the urls are 'http://www.everydayhealth.com/health-recipe/summer-vegetable-cr+\x8cpes.aspx?pos=3'

I am trying to save the network in gml format and it gives me the following error: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position 111: ordinal not in range(128)

Based on the links I read, I know that the url is a 'string' and not a 'unicode'. I checked it using type(url). But because it gives me the above error it means it does not contain all ASCII characters. So, I tried the following:

u1=url.decode('ascii') It gives me the following error: UnicodeDecodeError: 'ascii' codec can't decode byte 0x8c in position 64: ordinal not in range(128)

How should I go about it? My main purpose is to save this network in a gml format. Any help will be appreciated.

Thank You

1 Answer 1

1

have you tried to change encoding? this may help you https://docs.python.org/2/howto/unicode.html

Sign up to request clarification or add additional context in comments.

1 Comment

I did unicode(url, errors='ignore') and it worked. Thank you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.