Graphml解析错误 [英] Graphml parse error

查看:178
本文介绍了Graphml解析错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用python和igraph库创建一个graphml文件.我可以使用以下方法构造igraph的图形对象并将其写入文件:

g.write_graphml("mygraph.graphml")

一切似乎都成功了,但是当我尝试使用以下命令将文件读回到python时:

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

我收到此错误:

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

请问该如何解决? 非常感谢.

解决方案

我已经看到了库源代码.我认为库只能输出UTF-8 XML编码.因此,所有字符都必须使用UTF-8编码,并且如果文件中包含某些非UTF-8字符,则会引发错误.

解决方案:

您应按照此处

希望获得帮助.

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.

解决方案

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.

这篇关于Graphml解析错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆