简体   繁体   English

Graphml解析错误

[英]Graphml parse error

I tried to create a graphml file using python and igraph library. 我试图使用python和igraph库创建一个graphml文件。 I can construct igraph's graph object and wrote it to a file using: 我可以使用以下方法构造igraph的图形对象并将其写入文件:

g.write_graphml("mygraph.graphml")

Everything seems to be successful but when I tried to read the file back to python using: 一切似乎都成功了,但是当我尝试使用以下命令将文件读回python时:

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. 我认为库只能输出UTF-8 XML编码。 So all character must be UTF-8 encoding and if some non-UTF-8 character contains in file, Errors will be raised. 因此,所有字符都必须采用UTF-8编码,并且如果文件中包含某些非UTF-8字符,则会引发错误。

The Solution: 解决方案:

You should convert all string in your python application to UTF-8 encoding before use as describe here 您应该按照此处的说明使用之前,将python应用程序中的所有字符串转换为UTF-8编码

Hope this help. 希望对您有所帮助。

I think problem should come from Unicode invalid bytes sequence problem but without your file I can only guess. 我认为问题应该来自Unicode无效字节序列问题,但没有您的文件,我只能猜测。

I think you may load string from non-Unicode encoding file and use it directly without convert to Unicode encoding. 我认为您可以从非Unicode编码文件中加载字符串并直接使用它,而无需转换为Unicode编码。 Please try convert these strings to Unicode by see this post. 请尝试通过查看这篇文章将这些字符串转换为Unicode。

a busy cat http://goo.gl/CFGYf 忙碌的猫http://goo.gl/CFGYf

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM