2

I successfully created the nodes, but I was trying to create relationships between these nodes with the relationship type also to be retrieved from the csv on the run.

The query I was trying:

LOAD CSV FROM 'file:C:/temp.csv' AS line  
MATCH (node1:Keyword {name: line[0]}) 
MATCH  (node2:Keyword {name: line[1]}) 
CREATE (node1)-[:line[3] {weight: line[2]}]->(node2)

As you can see from the query I was trying to that pass on line[3] to be the relationship type retrieved dynamically from csv for every row instead of an unique predefined identifier.

This is the error I got:

Neo.ClientError.Statement.InvalidSyntax

Invalid input '[': expected an identifier character, whitespace, '|', a length specification, a property map or ']' (line 1, column 192 (offset: 191)) "LOAD CSV FROM 'file:C:/temp.csv' AS line MATCH (node1:Keyword {name: line[0]}) MATCH (node2:Keyword {name: line[1]}) CREATE (node1)-[:line[3] {weight: line[2]}]->(node2)"

And the (^) is placed under the '[' symbol in line[3] by neo4j compiler.

In my previous experiments I placed this line[3] as another relationship property along with the weight and it worked, but now while trying to store it as relationship type itself I hit this roadblock.

Am I doing something wrong or is there some other way to do it?

Any help is appreciated.

Thanks, Siva

Drakes
  • 23,254
  • 3
  • 51
  • 94
  • 2
    possible duplicate of [Neo4j cypher - Import CSV and add relationships between nodes based on the csv values](http://stackoverflow.com/questions/27720031/neo4j-cypher-import-csv-and-add-relationships-between-nodes-based-on-the-csv-v) See Stefans answer – Luanne Jun 24 '15 at 03:50
  • you can also use https://github.com/jexp/neo4j-shell-tools#cypher-import and use `#{type}` as placeholder – Michael Hunger Jun 25 '15 at 13:14
  • @Luanne , the referred question has only two different values to pick from, but in my case they keep on growing, because these csvs are created by a streaming application. For now I can use that as a short term solution since I have a working data set with 70 odd types. – Siva RamaKrishna Reddy Venna Jun 26 '15 at 00:09
  • Okay, then perhaps Load Csv is not for you. See the cypher import that Michael has referenced above – Luanne Jun 26 '15 at 03:14

0 Answers0