0
votes

I'm new to Neo4j and Cypher and I'm trying to import some data from csv that includes an array of IDs. I have the query below working but as Cypher defaults to strings, I've been unable to find the best way to convert the array of placeIDs to integers.

LOAD CSV WITH HEADERS FROM 'http://localhost:11001/project-ca45d786-e360-4e3b-b4b4-eb8fe62a7b55/People-Gridv2.csv' AS row
CREATE (:People {peopleID: toInteger(row.peopleID), nickname: row.nickname, firstName: row.firstName, lastName: row.lastName, relationship: row.relationship, firstMemory: row.firstMemory, lastMemory: row.lastMemory, placeID: split(row.placeID,";")})

I hoped that I'd be able to do something like the following, but it doesn't work:

placeID: toInteger(split(row.placeID,";"))

Can anyone point me in the right direction?

1

1 Answers

1
votes

that would probably something like

placeID : REDUCE(array=[] , s IN split(row.placeID,";") | array+[toInteger(s)] )

to get an array of integers

example

with '123;456' as placeID
return REDUCE(array=[] , s IN split(placeID,";") | array+[toInteger(s)] )

will return

[123,456]

and even shorter :)

with '123;456' as placeID
return [s IN split(placeID,";") | toInteger(s)]