|
USING PERIODIC COMMIT 10000 |
|
LOAD CSV WITH HEADERS FROM 'file:///Tracks.csv' as line |
|
WITH line, |
|
CASE |
|
WHEN toFloat(line.TEMPO) < 20 THEN "Larghissimo" |
|
WHEN toFloat(line.TEMPO) >= 20 AND toFloat(line.TEMPO) < 40 THEN "Grave" |
|
WHEN toFloat(line.TEMPO) >= 40 AND toFloat(line.TEMPO) < 60 THEN "Largo" |
|
WHEN toFloat(line.TEMPO) >= 60 AND toFloat(line.TEMPO) < 80 THEN "Adagio" |
|
WHEN toFloat(line.TEMPO) >= 80 AND toFloat(line.TEMPO) < 120 THEN "Moderato" |
|
WHEN toFloat(line.TEMPO) >= 120 AND toFloat(line.TEMPO) < 180 THEN "Allegro" |
|
ELSE "Presto" |
|
END as NamedTempo, |
|
CASE |
|
WHEN toFLoat(line.DANCEABILITY) < .25 THEN "S" |
|
WHEN toFLoat(line.DANCEABILITY) >= .25 AND toFLoat(line.DANCEABILITY) < .5 THEN "M" |
|
WHEN toFLoat(line.DANCEABILITY) >= .5 AND toFLoat(line.DANCEABILITY) < .75 THEN "L" |
|
ELSE "XL" |
|
END as Dance, |
|
CASE |
|
WHEN toFLoat(line.ENERGY) < .25 THEN "S" |
|
WHEN toFLoat(line.ENERGY) >= .25 AND toFLoat(line.ENERGY) < .5 THEN "M" |
|
WHEN toFLoat(line.ENERGY) >= .5 AND toFLoat(line.ENERGY) < .75 THEN "L" |
|
ELSE "XL" |
|
END as Energy, |
|
CASE |
|
WHEN toFLoat(line.VALENCE) < .25 THEN "S" |
|
WHEN toFLoat(line.VALENCE) >= .25 AND toFLoat(line.VALENCE) < .5 THEN "M" |
|
WHEN toFLoat(line.VALENCE) >= .5 AND toFLoat(line.VALENCE) < .75 THEN "L" |
|
ELSE "XL" |
|
END as Valence, |
|
CASE |
|
WHEN toFLoat(line.INSTRUMENTALNESS) < .25 THEN "S" |
|
WHEN toFLoat(line.INSTRUMENTALNESS) >= .25 AND toFLoat(line.INSTRUMENTALNESS) < .5 THEN "M" |
|
WHEN toFLoat(line.INSTRUMENTALNESS) >= .5 AND toFLoat(line.INSTRUMENTALNESS) < .75 THEN "L" |
|
ELSE "XL" |
|
END as Instrumentalness |
|
|
|
MERGE (tmp:Tempo {tempo:NamedTempo}) |
|
MERGE (d:DanceAbility {score:Dance}) |
|
MERGE (e:Energy {score:Energy}) |
|
MERGE (v:Valence {score:Valence}) |
|
MERGE (i:Instrumentalness {score:Instrumentalness}) |
|
MERGE (t:Track {trackId: line.TRACKID}) |
|
SET |
|
t.trackName=line.NAME, |
|
t.isrc=line.ISRC, |
|
t.popularity=line.POPULARITY |
|
|
|
MERGE (t)-[ht:HASTEMPO]->(tmp) SET ht.value = toFloat(line.TEMPO) |
|
MERGE (t)-[dt:DANCEABLE]->(d) SET dt.value = toFloat(line.DANCEABILITY) |
|
MERGE (t)-[et:ENERGETIC]->(e) SET et.value = toFloat(line.ENERGY) |
|
MERGE (t)-[hat:HAPPINESS]->(v) SET hat.value = toFloat(line.VALENCE) |
|
MERGE (t)-[it:INTRUMENTAL]->(i) SET it.value = toFloat(line.INSTRUMENTALNESS) |
|
|
|
WITH t, line |
|
MATCH (a:Artist {artistId:line.ARTISTID}) |
|
MERGE (a)-[:PERFORMED]->(t) |