Skip to content Skip to sidebar Skip to footer

Parsing Comments In Dot File With Python

I'm using pydot for parsing dot files in python. I can't find a way to parse comments present in the dot file itself, is there any way to do it? By just looking at the documentatio

Solution 1:

it is possible if you use the module json along with it like:

import pydot
import pyparsing
import json


graph = pydot.graph_from_dot_file(path)
edgeList = graph.get_edge_list() 
for e in edgeList:
      tempAttr = json.dumps(e.get_attributes())
      edgeAttr = json.loads(tempAttr)
      edgeAttr['insert_label_here']

Post a Comment for "Parsing Comments In Dot File With Python"