2

I want to load a dot file to python,using this

graph = pydot.graph_from_dot_file(tmp1)

nodeList = graph.get_node_list()

but I got error when the label of nodes in the dot file is like:

398 [shape=diamond, fillcolor="#CCCCCC", label="(int)*value == '\\"'"];

error message is like this:

  398 [shape=diamond, fillcolor="#CCCCCC", label="(int)*value == '\\\"'"];
      ^
Expected "}" (at char 1800), (line:34, col:7)
Traceback (most recent call last):
  File "dotchange.py", line 52, in <module>
    print dotchange(line)
  File "dotchange.py", line 13, in dotchange
    nodeList = graph.get_node_list()
AttributeError: 'NoneType' object has no attribute 'get_node_list'

It seem that the escape character "\" causes the error.

If I replace the label of the nodes containing "\" with "",the error disappear.

1
  • I had the similar issue so replacing node names containing characters '<','>' as below and above was the fix.
    – DACW
    Jun 3, 2016 at 23:01

0

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

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

Browse other questions tagged or ask your own question.