cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

CSV columns getting jumbled while exporting to linux server from neo4j

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

6 REPLIES 6

can you raise this as a GitHub issue for APOC?

Hello Michael,

Thanks for your inputs.
I have opened up a issue for APOC.

Lets wait for the further inputs.

Best Regards
Akshat

[root@jmngdprv009693 plugins]# ll
total 29448
-rwxrwxrwx 1 SIPGRAPHDB SIPGRAPHDB 13695353 Jul 23 13:46 apoc-3.5.0.3-all.jar
-rwxrwxrwx 1 SIPGRAPHDB SIPGRAPHDB 5970938 Jul 23 13:46 neo4j-jdbc-driver-3.4.0.jar
-rwxrwxrwx 1 SIPGRAPHDB SIPGRAPHDB 2739670 Jul 23 13:45 ojdbc6.jar
-rwxrwxrwx 1 SIPGRAPHDB SIPGRAPHDB 3698857 Jul 23 13:45 ojdbc7.jar
-rwxrwxrwx 1 SIPGRAPHDB SIPGRAPHDB 4036257 Jul 23 13:45 ojdbc8.jar
-rwxrwxrwx 1 SIPGRAPHDB SIPGRAPHDB 2217 Apr 3 12:39 README.txt

Use APOC 3.5.0.4 there was a bug earlier.

ameyasoft
Graph Maven

Looks like the order of column headers is being determined by your path variable 'p'.

Yes if you use a node, relationship or path, we sort the columns alphabetically to have consistency across multiple instances.