Data Formats

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

DSE Graph can ingest comma-delimited (CSV), JSON, or text data using the DSE Graph Loader. The DSE Graph Loader is a tool that can transform data upon ingestion if required, but complex transformations will make the data ingestion slow.

Gryo is a compact binary format, the fastest and most space-saving format for populating DSE Graph with data. This method can be used if the data has been generated from DSE Graph or another graph database.

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. GraphML is an XML-based file format that similarly passes both data and schema. It is widely supported by graph-related tools and libraries making it a solid interchange format for DSE Graph. GraphSON and GraphML are common formats and useful for importing data into DSE Graph from another graph database.

CSV

A CSV file is a common file format that can be input into DSE Graph. A sample of CSV graph data:
personId|name|nickname|gender|CALORIES|macroGoal
1|Julia Child|null|F||
2|Simone Beck|null|F||

JSON

A JSON file is a common file format that can be input into DSE Graph. A sample of JSON graph data:
{ "personId":1, "country": {"value":"USA", "startYear":1930, "endYear":1949 } }

Gryo

Writing data out of the graph into a Gryo file can be accomplished with a simple graph.io() command:
graph.io(gryo()).writeGraph("/tmp/recipe.gryo")

GraphSON

Writing data out of the graph into a GraphSON file can be accomplished with a simple graph.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"}},

GraphML

Writing data out of the graph into a GraphML file can be accomplished with a simple graph.io() command:
graph.io(graphml()).writeGraph("/tmp/recipe.gml")

A sample of the output of a GraphSON file:

<?xml version='1.0' encoding='UTF-8'?><graphml xmlns="http://graphml.graphdrawing.org/xmlns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://graphml.grap
hdrawing.org/xmlns http://graphml.graphdrawing.org/xmlns/1.1/graphml.xsd"><key id="instructions" for="node" attr.name="instructions" attr.type="string"/><key id="notes" for="node" attr.n
ame="notes" attr.type="string"/><key id="mealId" for="node" attr.name="mealId" attr.type="int"/><key id="gender" for="node" attr.name="gender" attr.type="string"/><key id="ingredId" for=
"node" attr.name="ingredId" attr.type="int"/><key id="type" for="node" attr.name="type" attr.type="string"/><key id="recipeId" for="node" attr.name="recipeId" attr.type="int"/><key id="b
ookId" for="node" attr.name="bookId" attr.type="int"/><key id="labelV" for="node" attr.name="labelV" attr.type="string"/><key id="publishYear" for="node" attr.name="publishYear" attr.typ
e="int"/><key id="ISBN" for="node" attr.name="ISBN" attr.type="string"/><key id="name" for="node" attr.name="name" attr.type="string"/><key id="personId" for="node" attr.name="personId"
attr.type="int"/><key id="labelE" for="edge" attr.name="labelE" attr.type="string"/><key id="amount" for="edge" attr.name="amount" attr.type="string"/><key id="createDate" for="edge" att
r.name="createDate" attr.type="string"/><graph id="G" edgedefault="directed"><node id="{~label=recipe, recipeId=2003}"><data key="labelV">recipe</data><data key="instructions">Take a sal
ad bowl or platter and line it with lettuce leaves, shortly before serving. Drizzle some olive oil on the leaves and dust them with salt.</data><data key="notes"></data><data key="name">
Salade Nicoise</data><data key="recipeId">2003</data></node><node id="{~label=recipe, recipeId=2005}"><data key="labelV">recipe</data><data key="instructions">Preheat the oven to 375 deg
rees F. Cook bacon in a large skillet over medium heat until very crisp and fat has rendered, 8-10 minutes.</data><data key="notes"> </data><data key="name">Spicy Meatloaf</data><data ke
y="recipeId">2005</data></node><node id="{~label=recipe, recipeId=2006}"><data key="labelV">recipe</data><data key="instructions">Saute the shallots, celery, herbs, and seasonings in 3 t
ablespoons of the butter for 3 minutes. Add the watercress and let it wilt.</data><data key="notes"> </data><data key="name">Oysters Rockefeller</data><data key="recipeId">2006</data></n
ode><node id="{~label=recipe, recipeId=2007}"><data key="labelV">recipe</data><data key="instructions">In a heavy-bottomed pot, melt the butter. When it starts to foam, add the onions an
d thyme and cook over medium-low heat until tender, about 10 minutes.</data><data key="notes">Quick and easy.</data><data key="name">Carrot Soup</data><data key="recipeId">2007</data></n
ode><node id="{~label=recipe, recipeId=2001}"><data key="labelV">recipe</data><data key="instructions">Braise the beef. Saute the onions and carrots. Add wine and cook in a dutch oven at
 425 degrees for 1 hour.</data><data key="notes">Takes a long time to make.</data><data key="name">Beef Bourguignon</data><data key="recipeId">2001</data></node><node id="{~label=recipe,
 recipeId=2002}"><data key="labelV">recipe</data><data key="instructions">Peel and cut the egglant. Make sure you cut eggplant into lengthwise slices that are about 1-inch wmyIde, 3-inch
es long, and 3/8-inch thick</data><data key="notes">I've made this 13 times.</data>