gqlalchemy.query_builders.memgraph_query_builder
QueryBuilder Objects
class QueryBuilder(DeclarativeBase)
load_csv
def load_csv(path: str, header: bool, row: str) -> "DeclarativeBase"
Load data from a CSV file by executing a Cypher query for each row.
Arguments:
path
- A string representing the path to the CSV file.header
- A bool indicating if the CSV file starts with a header row.row
- A string representing the name of the variable for iterating over each row.
Returns:
A DeclarativeBase
instance for constructing queries.
Examples:
Load CSV with header:
Python
-load_csv(path="path/to/my/file.csv", header=True, row="row").return_().execute()
Cypher
-LOAD CSV FROM 'path/to/my/file.csv' WITH HEADER AS row RETURN *;
Load CSV without header:
Python
-load_csv(path='path/to/my/file.csv', header=False, row='row').return_().execute()
Cypher
-LOAD CSV FROM 'path/to/my/file.csv' NO HEADER AS row RETURN *;