Data formats

DataStax Graph (DSG) handles many different formats. Each format has advantages, and the choice of which to use is a matter of preference.

DSG can ingest comma-delimited (CSV) or JSON using the DataStax Bulk Loader.

GraphSON is a JSON style file format that passes both data and schema in human-readable format. It is easy to work with, as the structure is evident, but it results in large files. GraphSON is a common formats and useful for importing data into DSG from another graph database. The protocol supported for DSG is GraphSON 3.

CSV

A CSV file is a common file format that can be input into DSG. A sample of CSV graph data:

person_id|name|nickname|gender|calories|macro_goal
1|Julia Child|null|F||
2|Simone Beck|null|F||

JSON

A JSON file is a common file format that can be input into DSG. A sample of JSON graph data:

{ "person_id":1, "country": {"value":"USA", "start_year":1930, "end_year":1949 } }

GraphSON

Writing data out of the graph into a GraphSON file can be accomplished with a g.io() command:

graph.io(graphson()).writeGraph("/tmp/recipe.gson")

A sample of the output of a GraphSON file:

{"id":{"@type":"g:Map","@value":["~label","recipe","recipeId",{"@type":"g:Int32","@value":2003}]},"label":"recipe","inE":{"created":[{"id":{"@type":"g:Map","@value":["~label","created","
~out_vertex",{"@type":"g:Map","@value":["~label","person","personId",{"@type":"g:Int32","@value":1}]},"~in_vertex",{"@type":"g:Map","@value":["~label","recipe","recipeId",{"@type":"g:Int
32","@value":2003}]},"~local_id",{"@type":"g:UUID","@value":"f38f9dd1-2978-11e8-8043-6bfe97ac83b9"}]},"outV":{"@type":"g:Map","@value":["~label","person","personId",{"@type":"g:Int32","@
value":1}]},"properties":{"createDate":{}}}]},"outE":{"includedIn":[{"id":{"@type":"g:Map","@value":["~label","includedIn","~out_vertex",{"@type":"g:Map","@value":["~label","recipe","rec
ipeId",{"@type":"g:Int32","@value":2003}]},"~in_vertex",{"@type":"g:Map","@value":["~label","book","bookId",{"@type":"g:Int32","@value":1001}]},"~local_id",{"@type":"g:UUID","@value":"f3
90fd61-2978-11e8-8043-6bfe97ac83b9"}]},"inV":{"@type":"g:Map","@value":["~label","book","bookId",{"@type":"g:Int32","@value":1001}]}},{"id":{"@type":"g:Map","@value":["~label","includedI
n","~out_vertex",{"@type":"g:Map","@value":["~label","recipe","recipeId",{"@type":"g:Int32","@value":2003}]},"~in_vertex",{"@type":"g:Map","@value":["~label","ingredient","ingredId",{"@t
ype":"g:Int32","@value":3008}]},"~local_id",{"@type":"g:UUID","@value":"f3903a15-2978-11e8-8043-6bfe97ac83b9"}]},"inV":{"@type":"g:Map","@value":["~label","ingredient","ingredId",{"@type
":"g:Int32","@value":3008}]},"properties":{"amount":"2-3 Tbsp"}},{"id":{"@type":"g:Map","@value":["~label","includedIn","~out_vertex",{"@type":"g:Map","@value":["~label","recipe","recipe
Id",{"@type":"g:Int32","@value":2003}]},"~in_vertex",{"@type":"g:Map","@value":["~label","ingredient","ingredId",{"@type":"g:Int32","@value":3010}]},"~local_id",{"@type":"g:UUID","@value
":"f3903a16-2978-11e8-8043-6bfe97ac83b9"}]},"inV":{"@type":"g:Map","@value":["~label","ingredient","ingredId",{"@type":"g:Int32","@value":3010}]},"properties":{"amount":"1 1/2 lbs blanch
ed, trimmed"}},

Was this helpful?

Give Feedback

How can we improve the documentation?

© 2024 DataStax | Privacy policy | Terms of use

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: +1 (650) 389-6000, info@datastax.com