1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Python] How to export TopologicPy graph to Neo4j

Discussão em 'Python' iniciado por Stack, Setembro 12, 2024.

  1. Stack

    Stack Membro Participativo

    I am trying to store a TopologicPy graph in Neo4j. I tried the codes below according to the TopologicPy documentation:

    from topologicpy.Topology import Topology
    from topologicpy.Graph import Graph
    from topologicpy import Neo4j

    IFC_file_path = "sample.ifc"
    graph_topo = Graph.ByIFCPath(IFC_file_path)

    username="..."
    password="..."
    url="..."

    graph_neo4j = Neo4j.Neo4j.ByParameters(url=url, username=username, password=password)
    topo_neo4j = Neo4j.Neo4j.AddGraph(neo4jGraph=graph_neo4j, graph=graph_topo, labelKey='None', relationshipKey='None')


    But I got the error below. Anyone knows where the problem is? Are there some ways to store a TopologicPy graph to Neo4j? Thanks!

    ---------------------------------------------------------------------------
    AttributeError Traceback (most recent call last)
    Cell In[5], line 4
    1 # Create an instance of the Neo4j graph
    2 graph_neo4j = Neo4j.Neo4j.ByParameters(url=url, username=username, password=password)
    ----> 4 topo_neo4j = Neo4j.Neo4j.AddGraph(neo4jGraph=graph_neo4j, graph=graph_topo, labelKey='None', relationshipKey='None')

    File c:\Users\Howie.Liu\AppData\Local\miniforge3\envs\graphrag\lib\site-packages\topologicpy\Neo4j.py:336, in Neo4j.AddGraph(neo4jGraph, graph, labelKey, relationshipKey, mantissa, tolerance)
    334 nodeName = str(values[keys.index(labelKey)])
    335 n = py2neo.Node(nodeName, **pydict)
    --> 336 neo4jGraph.cypher.execute("CREATE INDEX FOR (n:%s) on (n.name)" %
    337 n.nodelabel)
    338 tx.create(n)
    339 nodes.append(n)

    AttributeError: 'Graph' object has no attribute 'cypher'

    Continue reading...

Compartilhe esta Página