Hey folks - I am struggling a bit with my syntax for SPLIT and UNWIND. I think I am close, but I am getting some weird type errors...
I have a CSV that looks like the following:
rel-vmtods.csv
,VM Name,Datastore
0,KALPWVAPPEDGE01,"BGHVMAX250_01ba, BGHVMAX250_01bb"
1,KALCEXPEXT01,BGHVMAX250_01ba
2,KALTWVINTOAUT02,BGHVMAX250_01ba
3,KALSFTP02,BGHVMAX250_01bb
4,KALPWVAPPEDGE02,"BGHVMAX250_01ba, BGHVMAX250_01bb"
5,VSHPDMDMZ01,BGHVMAX250_01bb
6,VSWEBEXT01,BGHVMAX250_01ba
As you can see, when the CSV was generated (output from Pandas) some of the rows contain a single datastore, but some contain multiples and are quoted. Also Pandas apparently stuck an ID column in there with no header...
Anyways, I am using the following code to try to import the data - objects have already been created, so all I have to do is match them and create a relationship:
LOAD CSV WITH HEADERS FROM 'file:///rel-vmtods.csv' AS vmdsrow
//WITH vmdsrow.`VM Name` AS impVM, vmdsrow.Datastore AS impDS
WITH vmdsrow.`VM Name` AS impVM, SPLIT(vmdsrow[2], ",") AS multiDS
UNWIND multiDS as impDS
MATCH (vm:VM {VMName: impVM})
MATCH (ds:Datastore {DatastoreName:impDS})
MERGE (vm)-[rel:IS_STORED_ON]->(ds)
However I am receiving the following error if I use "SPLIT" -
Expected Long(1) to be a org.neo4j.values.storable.TextValue, but it was a org.neo4j.values.storable.LongValue (Failure when processing file '/Users/username/Library/Application%20Support/com.Neo4j.Relate/Data/dbmss/dbms-ce00a1b5-549e-4941-a09e-1221aac8a74b/import/rel-vmtods.csv' on line 2.)
If I uncomment the second line (and comment out the 3rd) it runs fine - but obviously it doesn't successfully match on any rows with multiple values in column 3, so I only get a fraction of the necessary relationships created.