nireak
nireak

Reputation: 23

Filter csvlines before inserting the values in cypher

I'm using the LOAD CSV inside cypher to populate my database. I would like to skip lines with blank values in specific field before creating the node in neo4j.

I've tried something like:

LOAD CSV WITH HEADERS FROM "https://dl.dropboxusercontent.com/..../file.csv" AS csvline

MATCH csvline WHERE csvline.name <>""

WITH csvline
MERGE (n {name: csvline.name})

but I get the following error "Cannot match on a pattern containing only already bound identifiers"

Thank you

Upvotes: 2

Views: 1761

Answers (1)

Bossie
Bossie

Reputation: 3612

Are you using Neo4j 2.1.2 by any chance? I bumped into this error message yesterday.

Try:

LOAD CSV WITH HEADERS FROM "https://dl.dropboxusercontent.com/..../file.csv" AS csvline
WITH csvline
WHERE csvline.name <>""
MERGE ({name: csvline.name});

(Notice you don't need the n identifier since you never use it.)

Cheers.

Upvotes: 5

Related Questions