Graphml parse error

我只是一个虾纸丫 提交于 2019-12-02 09:36:21

问题


I tried to create a graphml file using python and igraph library. I can construct igraph's graph object and wrote it to a file using:

g.write_graphml("mygraph.graphml")

Everything seems to be successful but when I tried to read the file back to python using:

g = Graph.Read_GraphML('mygraph.graphml')

I got this error:

igraph.core.InternalError: Error at .\src\foreign-graphml.c:1024: 
Input is not proper UTF-8, indicate encoding ! Bytes: 0xA0 0x3C 0x2F 0x64

How can I solve this, please? Thank you very much.


回答1:


I already see the libary source code. I think library can output only UTF-8 XML Encoding. So all character must be UTF-8 encoding and if some non-UTF-8 character contains in file, Errors will be raised.

The Solution:

You should convert all string in your python application to UTF-8 encoding before use as describe here

Hope this help.




回答2:


I think problem should come from Unicode invalid bytes sequence problem but without your file I can only guess.

I think you may load string from non-Unicode encoding file and use it directly without convert to Unicode encoding. Please try convert these strings to Unicode by see this post.

a busy cat http://goo.gl/CFGYf



来源:https://stackoverflow.com/questions/8955797/graphml-parse-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!