0

I am working on loading csv file from dataloader in datastax graph.

My csv files structure is following

first file(Year_2015.txt)

YearID

second file(BaseVehicle_2005.txt)

BaseVehicleID|YearID|MakeID|ModelID

for first file I have create vertex level as year and key as YearID for second I have create vertex level as BaseVehicle while key as BaseVehicleID and ignore YearID,MakeID,ModelID. Now I want to create edge between second(BaseVehicle) and first(Year) with edge level year and property YearID but nothing has work for me. Please let me know what i need to change?

stephen mallette
  • 45,298
  • 5
  • 67
  • 135

1 Answers1

0

The documentation has examples : https://docs.datastax.com/en/latest-dse/datastax_enterprise/graph/dgl/dglCSV.html

Below is a sample loader script that works on JSON data, but it shows how to load both Vertices and Edges from the same record, using mappers to decide which elements to use.


config load_threads: 8
config batch_size: 1000
config load_new: true
config driver_retry_attempts: 10
config driver_retry_delay: 1000

/** SAMPLE INPUT
  {"actor_name":"'Bear'Boyd, Steven","title_name":"The Replacements","year":"2000","role":"Defensive Tackle - Washington Sentinels","episode":"The Replacements"}
 */
input = File.json(filename )

//Defines the mapping from input record to graph elements
actorMapper = {
    key "actor_name"           // the unique id for an actor
    label "actor"
    ignore "title_name"
    ignore "role"
    ignore "year"
    ignore "episode"
}

titleMapper = {
    key "title_name"           // the unique id for a title
    label "title"
    ignore "sex"
    ignore "actor_name"
    ignore "role"
    ignore "episode"
}

castMapper = {
    label "cast"
    outV "actor_name", {
        label "actor"
        key "actor_name"
    }
    inV "title_name", {
        label "title"
        key "title_name"
    }
    ignore "year"
    ignore "sex"
    // remaining should be edge properties
    // pickup role as property
    // pickup episode as property
}

//Load vertex records from the input according to the mapping
load(input).asVertices(actorMapper)
load(input).asVertices(titleMapper)
load(input).asEdges(castMapper)
martinvr
  • 171
  • 3