Hello Team,
I am facing issuing where I am trying to export a result of cypher query in CSV , where columns and their values are getting jumbled.
Below are my cases with queries and results:
Case 1: CSV columns and values are getting jumbled
Query
call apoc.export.csv.query("MATCH p=(a:EntCust)-[r:Cust2Srv]-(b:EntSrv)-[r1:Srv2Path]-(c:EntPath)-[r2:APPath2PS]-(d:EntAPPriSec)-[r3:PSPath2Gige]-(e:EntGigePath)-[r4:Gige2LogicalPort]-(f:EntL23Port) where split(b.ServiceAMO,'')[3] is not null
return
f.Name as CINAME,
b.Name as CIRCUIT_ID,
a.CustID as CUSTOMER_ID,
(split(b.ServiceAMO,'')[3]) as SERVICE_ID,
a.Name as CUSTOMER_NAME,
null as PROTECTION", "/tmp/harsha4.csv",{d:','});
Result:-
[root@sitdp tmp]# head -4 harsha4.csv
"CINAME","CIRCUIT_ID","CUSTOMER_ID","CUSTOMER_NAME","PROTECTION","SERVICE_ID"
"L3 Port:INKLATNGATNGTW6001ENBPAR001:GigabitEthernet0/4/5.2103","WiFi_9030029491_916186218994","9030029491","916186218994","Wifioffice",""
"L3 Port:INKLATNGATNGTW6001ENBEDR002:GigaEthernet0/3.2103","WiFi_9030029491_916186218994","9030029491","916186218994","Wifioffice",""
"L3 Port:INKLATNGATNGTW6001ENBPAR001:GigabitEthernet0/4/5.2103","WiFi_9030029491_916186218663","9030029491","916186218663","Wifioffice",""
Case 2:- CSV columns are aligned correctly with their values by just changing the null value column position in export csv
Query:
call apoc.export.csv.query("MATCH p=(a:EntCust)-[r:Cust2Srv]-(b:EntSrv)-[r1:Srv2Path]-(c:EntPath)-[r2:APPath2PS]-(d:EntAPPriSec)-[r3:PSPath2Gige]-(e:EntGigePath)-[r4:Gige2LogicalPort]-(f:EntL23Port) where split(b.ServiceAMO,'')[3] is not null
return
f.Name as CINAME,
b.Name as CIRCUIT_ID,
a.CustID as CUSTOMER_ID,
a.Name as CUSTOMER_NAME,
null as PROTECTION,
(split(b.ServiceAMO,'')[3]) as SERVICE_ID", "/tmp/harsha2.csv",{d:','});
CSV result:
[root@sitdp tmp]# head -4 harsha2.csv
"CINAME","CIRCUIT_ID","CUSTOMER_ID","CUSTOMER_NAME","PROTECTION","SERVICE_ID"
"L3 Port:INKLATNGATNGTW6001ENBPAR001:GigabitEthernet0/4/5.2103","WiFi_9030029491_916186218994","9030029491","Wifioffice","","916186218994"
"L3 Port:INKLATNGATNGTW6001ENBEDR002:GigaEthernet0/3.2103","WiFi_9030029491_916186218994","9030029491","Wifioffice","","916186218994"
"L3 Port:INKLATNGATNGTW6001ENBPAR001:GigabitEthernet0/4/5.2103","WiFi_9030029491_916186218663","9030029491","Wifioffice","","916186218663"
Please help me in telling why this is happening?
[root@sitdp bin]# ./neo4j version
neo4j 3.5.4
[root@sitdp bin]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.4 (Maipo)
Best Regards
Akshat