0

I want to specify a list as the values of a property in csv file so that it can be loaded through load_csv as list.

Currently, I am specifying it as string and using split to add it in to list as below. Is there a better way?

WITH n, split(n.lab, \",\") as labels limit {limit}
call apoc.create.addLabels(id(n), labels)

Is there a way to avoid using split by reading it as list while doing load_csv. what's the syntax of list in csv file?

1 Answer 1

1

With LOAD CSV, each line in a CSV file without headers is accessed as a list, so you can just leave each label as a separate item in the line and generate a new list from those items.

For example, if each line starts with a node ID and ends with 1 or more labels:

LOAD CSV FROM '...' AS line
CALL apoc.create.addLabels(TOINTEGER(line[0]), line[1..]);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.