cypher-shell icon indicating copy to clipboard operation
cypher-shell copied to clipboard

add a json option to cypher shell's --format argument

Open eastlondoner opened this issue 5 years ago • 1 comments

This would allow for scripting cypher shell with jq. Currently scripting with cypher is extremely onerous because it's necessary to

  1. strip out headers
  2. split output rows into columns
  3. remove quotes around columns
  4. deal with the character escaping applied to the contents of columns

eastlondoner avatar Sep 10 '19 10:09 eastlondoner

for example to pipe the cypher shell output of apoc.export.cypher back in to cypher shell I need this:

sed 's/^":/:/' | sed 's/^"$/:/' | sed 's/\\"/"/g' | sed 's/^:$//' | tail -n +2 \

and that's with well behaved data (no weird string values in)

as in

cypher-shell --format plain -u neo4j -p "${neo4j_password}" "call apoc.export.cypher.all(null,{format:'cypher-shell', streamStatements:true, batchSize:100, useOptimizations: {type: 'unwind_batch_params', unwindBatchSize:100}}) YIELD cypherStatements RETURN cypherStatements" \
 | sed 's/^":/:/' | sed 's/^"$/:/' | sed 's/\\"/"/g' | sed 's/^:$//' | tail -n +2 \
 | ./bin/cypher-shell --non-interactive --format plain -a bolt+routing://${other_neo4j_address} -u neo4j -p "${other_neo4j_password}"

eastlondoner avatar Sep 10 '19 18:09 eastlondoner