Loading file with column names specified instead of positional parameters

I am trying to create a TigerGraph loading job to use column names from the header line instead of positional parameters like $1, $2 etc. In order to use files external to TigerGraph server, I believe we need to specify the HEADER and INPUT_LINE_FILTER and use them in the loading job. However, I am unable to find any examples in TigerGraph documentation. My attempt below is now working.

Any help is appreciated.

result = conn.gsql('''
USE GRAPH MyGraphCopy 

BEGIN
CREATE LOADING JOB load_persons_byname FOR GRAPH MyGraphCopy {
      DEFINE FILENAME MyDataSource;
      DEFINE HEADER MyHeader = "id","name","email","username","created_at","v_id";
      DEFINE INPUT_LINE_FILTER reject_header = ( "created_at " = "created_at");
      LOAD MyDataSource TO VERTEX Person VALUES($"v_id", $"name", $"email", $"username", $"created_at") USING SEPARATOR=",", HEADER="true", USER_DEFINED_HEADER=MyHeader, REJECT_LINE_RULE=reject_header, EOL="\n", QUOTE="double";
    }
END
''')

print(result)

@rupen I think this is the documentation section you are looking for https://docs.tigergraph.com/gsql-ref/current/ddl-and-loading/creating-a-loading-job#_define_statements

@Jon_Herke The doc link is very helpful. I was finally able to get this version to work.

USE GRAPH MyGraphCopy 

BEGIN
CREATE LOADING JOB load_persons_byname FOR GRAPH MyGraphCopy {
      DEFINE FILENAME MyDataSource;
      DEFINE HEADER MyHeader = "id","name","email","username","created_at","v_id";
      DEFINE INPUT_LINE_FILTER reject_header = ( $4 == "created_at");
      LOAD MyDataSource TO VERTEX Person VALUES($"v_id", $"name", $"email", $"username", $"created_at") USING SEPARATOR=",", HEADER="true", USER_DEFINED_HEADER="MyHeader", REJECT_LINE_RULE=reject_header, EOL="\n", QUOTE="double";
    }
END
1 Like