How to export a a set of connected nodes to csv

Vendor_Id Test_Grp
1 S1
2 S1
3 S1
4 S2
5 S2
3 S2
6 S3
7 S3
8 S3
9 S4
10 S4
8 S4

As you can see in the above data , we have Vendor_id “3” under 2 groups S1 and S2 . So this will act as a link to club vendor_id’s 1 – 5 under a single cluster . Similary we have vendor_id “8” appearing twice in groups S3 and S4 which will put vendor_id’s 6- 10 under a single cluster . I am able to achieve this . However i need to get output in the below format to export to csv

Vendor_Id Test_Grp Cluster
1 S1 A
2 S1 A
3 S1 A
4 S2 A
5 S2 A
3 S2 A
6 S3 B
7 S3 B
8 S3 B
9 S4 B
10 S4 B
8 S4 B


It is not completely clear to me can you share your model?
If you know the Cluster you could create a Cluster Node also.
Than to get to a csv output you can do as follows:

MATCH (v:Vendor)-->(g:Group)-->(c:Cluster)
RETURN v.Vendor_Id as Vendor_Id , as Test_Grp, as Cluster

Does this help?


Try apoc.export seen here:

specifically if you have a query which gets the results you want already then you should run:

note: you need to set the config file to allow export with apoc (and install apoc) - ```