cypher-shell
cypher-shell copied to clipboard
add a json option to cypher shell's --format argument
This would allow for scripting cypher shell with jq
.
Currently scripting with cypher is extremely onerous because it's necessary to
- strip out headers
- split output rows into columns
- remove quotes around columns
- deal with the character escaping applied to the contents of columns
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}"