How to specify relationship type in CSV?

ekkis

I have a CSV file with data like:

ID,Name,Role,Project
1,James,Owner,TST
2,Ed,Assistant,TST
3,Jack,Manager,TST

and want to create people whose relationships to the project are therein specified. I attempted to do it like this:

load csv from 'file:/../x.csv' as line 
match (p:Project {code: line[3]}) 
create (n:Individual {name: line[1]})-[r:line[2]]->(p);

but it barfs with:

Invalid input '[': expected an identifier character, whitespace, '|', a length specification, a property map or ']' (line 1, column 159 (offset: 158))

as it can't seem to dereference line in the relationship creation. if I hard-code that it works:

load csv from 'file:/../x.csv' as line 
match (p:Project {code: line[3]}) 
create (n:Individual {name: line[1]})-[r:WORKSFOR]->(p);

so how do I make the reference?

Michael Hunger

Right now you can't as this is structural information.

Either use neo4j-import tool for that.

Or specify it manually as you did, or use this workaround:

load csv with headers from 'file:/../x.csv' as line 
match (p:Project {code: line.Project}) 
create (n:Individual {name: lineName})
foreach (x in case line.Role when "Owner" then [1] else [] end |
  create (n)-[r:Owner]->(p)
)
foreach (x in case line.Role when "Assistant" then [1] else [] end |
  create (n)-[Assistant]->(p)
)
foreach (x in case line.Role when "Manager" then [1] else [] end |
  create (n)-[r:Manager]->(p)
)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to specify relationship type in CSV?

From Dev

How to specify type for a variable?

From Dev

How to specify pivot table for hasOne() relationship in Laravel

From Dev

How to not specify the data type of arguments?

From Dev

How to specify data type for hashtable?

From Dev

How to specify name of configuration type?

From Dev

How to specify type for lambda expression?

From Dev

How to replace relationship field type object IDs with names / titles in KeystoneJS list CSV download / export?

From Java

How to specify "nullable" return type with type hints

From Dev

How to specify "own type" as return type in Kotlin

From Dev

How to specify "nullable" return type with type hints

From Dev

How can I specify a relationship between parameter estimates in lm?

From Dev

How to specify Amazon AWS User Pool in trust relationship with Cognito Identity

From Dev

how to specify the datetime format in read_csv

From Dev

How to specify a certain csv in the errorbar line

From Dev

How to specify a parameter of type Array into a Django Command?

From Dev

How to specify a number range as a type in Idris?

From Dev

In Pycharm, how to specify unions for type hinting?

From Dev

How can I specify a return type for operator[]?

From Java

How to specify a return type if it is behind a private module?

From Dev

How to specify a generic type for a function parameter

From Dev

How to explicitly specify variables as type dynamic?

From Dev

How to specify type when using ConcurrentHashMap in clojure

From Dev

How to specify type of a class in the app.config?

From Dev

PHP Doc - How to specify the exact abstract type?

From Dev

How to specify the return type of the method of an abstract class

From Dev

How to specify type of input data for Pandas DataFrame

From Dev

How to dynamically specify type in TypeScript generics?

From Dev

Hibernate: How to specify @ColumnDefault for Column of type enum

Related Related

  1. 1

    How to specify relationship type in CSV?

  2. 2

    How to specify type for a variable?

  3. 3

    How to specify pivot table for hasOne() relationship in Laravel

  4. 4

    How to not specify the data type of arguments?

  5. 5

    How to specify data type for hashtable?

  6. 6

    How to specify name of configuration type?

  7. 7

    How to specify type for lambda expression?

  8. 8

    How to replace relationship field type object IDs with names / titles in KeystoneJS list CSV download / export?

  9. 9

    How to specify "nullable" return type with type hints

  10. 10

    How to specify "own type" as return type in Kotlin

  11. 11

    How to specify "nullable" return type with type hints

  12. 12

    How can I specify a relationship between parameter estimates in lm?

  13. 13

    How to specify Amazon AWS User Pool in trust relationship with Cognito Identity

  14. 14

    how to specify the datetime format in read_csv

  15. 15

    How to specify a certain csv in the errorbar line

  16. 16

    How to specify a parameter of type Array into a Django Command?

  17. 17

    How to specify a number range as a type in Idris?

  18. 18

    In Pycharm, how to specify unions for type hinting?

  19. 19

    How can I specify a return type for operator[]?

  20. 20

    How to specify a return type if it is behind a private module?

  21. 21

    How to specify a generic type for a function parameter

  22. 22

    How to explicitly specify variables as type dynamic?

  23. 23

    How to specify type when using ConcurrentHashMap in clojure

  24. 24

    How to specify type of a class in the app.config?

  25. 25

    PHP Doc - How to specify the exact abstract type?

  26. 26

    How to specify the return type of the method of an abstract class

  27. 27

    How to specify type of input data for Pandas DataFrame

  28. 28

    How to dynamically specify type in TypeScript generics?

  29. 29

    Hibernate: How to specify @ColumnDefault for Column of type enum

HotTag

Archive