I have an array of strings as property value, and what's the cypher command to convert it as an array?
string_property = ["a", "b", "c"]
This is. a string with array format. I want to change it into this format when exporting the graph:
string_property = "a|b|c"
I need to use it in the export procedure:
MATCH (m:Sports)
WITH collect(DISTINCT m) AS M
CALL apoc.export.csv.data( M, [], null, {stream:true, batchSize:2000000}) YIELD data
WITH apoc.text.replace(data, '(?:,"_start","_end","_type"|,,,)(?=\n)', '') AS mdata
WITH REDUCE(reduced="", term IN mdata | reduced+term+'|') as reducedStr
WITH LEFT(reducedStr,SIZE(reducedStr)-1) as mdata
RETURN mdata
The REDUCE isn't quite right, since mdata is a string produced by apoc.text.replace(), not an array. My goal is to export the array of property from the original:
["a", "b", "c"]
to
"a|b|c"
So I need to manipulate the string created by apoc.export.csv.data. The REDUCE shouldn't work, since mdata is a big string with everything in it. I still need to use something like 'replace' to change the format of the string.
If that's hard, I can do it the other way: in loading csv, I can convert the string to an array:
string_property = ["a", "b", "c"]
The split function can not do this.