Tuesday, July 19, 2022

[FIXED] How to split an integer using cypher Ne04j

Issue

I have been trying to split the Half-time as I only require one of the two digits.

CSV file:

Round,Date,Team1,FT,HT,Team2
1,(Sat) 12 Aug 2017 (32),Chelsea FC,2-3,0-3,Burnley FC
1,(Sat) 12 Aug 2017 (32),Crystal Palace FC,0-3,0-2,Huddersfield Town AFC

LOAD CSV FROM WITH HEADERS "file:///epl_mataches.csv" AS row 
CREATE (t:team1{RoundtoInteger(row.Round), date:row.date, Team1:row.Team1,
FT:split(row.FT), HT:row.HT})

thank you


Solution

The result of the split function is a list. To get the first item on a list, you use the index 0.

 RETURN split('2-3', '-')[0]

 Result:  2

So in your query, use FT:split(row.FT, '-')[0]



Answered By - jose_bacoy
Answer Checked By - Timothy Miller (PHPFixing Admin)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.