Extension: Geoff

Maintained by: Nigel Small <nigel@py2neo.org>

Geoff is a text-based interchange format for Neo4j graph data that should be instantly readable to anyone familiar with Cypher, on which its syntax is based. For more information on the format itself, see here.

The Geoff extension for py2neo consists of a writer and a loader API. A command line tool is also provided for easy access to the load functionality. The loader itself requires a server plugin to be installed called load2neo.


class py2neo.ext.geoff.GeoffWriter(file=None, **kwargs)[source]

Writer for Geoff data. This can be used to write to any file-like object, such as standard output:

>>> from py2neo import Node
>>> from py2neo.ext.geoff import GeoffWriter
>>> import sys
>>> writer = GeoffWriter(sys.stdout)
>>> writer.write(Node("Person", name="Alice"))
(139895901379856:Person {"name":"Alice"})

Write any entity, value or collection.


Write an identifier.


Write a list.


Write a map.

write_node(name, labels=None, properties=None, unique_label=None, unique_key=None)[source]

Write a node.


Write a py2neo.Path.

write_rel(type_, properties=None, unique=False)[source]

Write a forward relationship (excluding nodes).

write_rev(type_, properties=None, unique=False)[source]

Write a reverse relationship (excluding nodes).


Write a py2neo.Subgraph.


Write a value.


class py2neo.ext.geoff.GeoffLoader(graph, path='/load2neo/')[source]

A wrapper for the load2neo unmanaged extension.


Load Geoff data from a string.


The version of server extension currently installed.


Load XML data by first converting to Geoff format.

class py2neo.ext.geoff.NodeDictionary(graph, data)[source]

A set of nodes returned from a successful Geoff load operation. Each node is keyed by the identifier used in the original Geoff data.


Get the node reference string for the node identified by the given key.


Fetch a list of all key-node pairs, each returned as a 2-tuple.


Fetch a list of all node keys.


Fetch a list of all nodes.

Command Line

A command line tool, geoff is installed as part of this extension. This gives access to the GeoffLoader class and can be used as follows:

$ geoff load '(alice:Person {"name":"Alice"})<-[:KNOWS]->(bob:Person {"name":"Bob"})'
alice node/1
bob   node/2

Instead of providing data inline, a file name can be specified instead using the -f option:

$ geoff load -f abba.geoff
abba     node/1648
agnetha  node/1649
benny    node/1655
björn    node/1650
frida    node/1653
waterloo node/1654

XML files can also be passed using the -x option. These will be converted to Geoff before loading:

$ geoff load -x -f abba.xml
abba     node/1668
agnetha  node/1669
benny    node/1670
björn    node/1652
frida    node/1664
waterloo node/1665