0

Im working with GQLAlchemy and was wondering how to properly use WITH clause and import a CSV file with headers using Memgraph’s GQLAlchemy.

MPesi
  • 212
  • 8

1 Answers1

0

For example,

match().node(variable=“n”).with_({“n”: “node”})….

it is with underscore method in the query builder and an argument is a dictionary that in the above example means:

WITH n AS node

Importing CSV files with (or without) headers using GQLAlchemy can be done by executing a Cypher query. Check out how the CSV files with a header were imported in our workshop. For example:

memgraph.execute(     
"""LOAD CSV FROM "/movies.csv" 
WITH HEADER AS row     
MERGE (m:Movie {id: toInteger(row.movieId), title: row.title})     
WITH m, row     
UNWIND split(row.genres, '|') as genre     
MERGE (m)-[:OF_GENRE]->(:Genre {name: genre});     
""" )
MPesi
  • 212
  • 8