UNWIND a string(in form of list) and create nodes

Hi all, I am loading a csv which looks like this:

When loaded in graph, the 'OTHER_MEDS' column has a datatype of string ofcourse (but in form of a list ie: it looks like a list). I now want that each 'VAERS_ID' node should be mapped to the nodes which are all present in the corresponding 'OTHER_MEDS' column.

For eg:
the node '916623' (of label person) should be mapped to 'wellbutrin', 'vitamin d3', 'zinc sulphate', 'collagen' where all these are 4 different nodes of label medicine. I tried using UNWIND and FOREACH, but was unsuccesful.
Thank you in advance!

Hi Abhisshek,

You have to eliminate the brakets and the apostrophe using regreplace. Then you can use split.
As there is a space between comma and next entry, you might need to remove this space first

with "('levothyroxine', 'phentermine', 'lithium', 'abilify lamictal')" as a
with apoc.text.split(
    apoc.text.regreplace (
        apoc.text.replace(a, "', '", "','"), 
    ",") as c
return c

c is then a list.

Hi Benoit, thank you for your answer! After obtaining the list, how can I create the nodes from that list? And also, how can I link 'VAERS_ID' to the nodes created through the list?

For the reference, it should look like this:
(will be doing this for every 'VAERS_ID)

Hi @Benoit_d , I was able to create the nodes and relationships using these queries:

WITH line.OTHER_MEDS as meds, adverse_event
WITH split(replace(replace(replace(meds,"', '",","),"['",''),"']",''),',') as meds1,adverse_event
UNWIND meds1 as x
CREATE (adverse_event)-[:previous]->(a)

Thank you for your help! :slight_smile: