Test this one. You also could change the batch size of the transactions by uncommenting the //OF 500 rows
otherwise the defaultsize is 1000
:auto load csv with headers from "file:///locations.csv" as row with row
with row
call{
with row
with row,keys(row) as columns
merge (token:tokens {name:row.Token})
with row,columns,token
unwind range(0,size(columns)) as columnIndex
with row,columns[columnIndex] as columnName,token
where not columnName='Token' and not row[columnName] is null
merge (l1:locations {name:row[columnName]})
with token,columnName,l1
call apoc.merge.relationship(token,columnName,null,null,l1,null)
yield rel
return rel
} IN TRANSACTIONS //OF 500 ROWS
return count(rel)