下面的加载作业假设您的数据文件位于文件夹/home/tigergraph中。如果它们在其他地方,则在下面的加载作业脚本中替换“/home/tigergraph/person”。csv和“/ home / tigergraph/friendship.csv"和它们对应的文件路径。假设您(回到)GSQL shell中,输入以下命令集:
GSQL commands to define a loading job
USE GRAPH socialBEGINCREATE LOADING JOB load_social FOR GRAPH social { DEFINE FILENAME file1="/home/tigergraph/person.csv"; DEFINE FILENAME file2="/home/tigergraph/friendship.csv"; LOAD file1 TO VERTEX person VALUES ($"name", $"name", $"age", $"gender", $"state") USING header="true", separator=",";
LOAD file2 TO EDGE friendship VALUES ($0, $1, $2) USING header="true", separator=",";}END
GSQL >USE GRAPH socialUsing graph 'social'GSQL >BEGINGSQL >CREATE LOADING JOB load_social FOR GRAPH social {GSQL > DEFINE FILENAME file1="/home/tigergraph/person.csv";GSQL > DEFINE FILENAME file2="/home/tigergraph/friendship.csv";GSQL >GSQL > LOAD file1 TO VERTEX person VALUES ($"name", $"name", $"age", $"gender", $"state") USING header="true", separator=",";
GSQL >LOAD file2 TO EDGE friendship VALUES ($0, $1, $2) USING header="true", separator=",";GSQL > }GSQL >ENDThe job load_social is created.
运行一个加载的工作
现在可以运行加载作业,将数据加载到图中:
GSQL command
RUN LOADING JOB load_social
结果显示如下:
GSQL shell
GSQL>runloadingjobload_social[Tip: Use "CTRL + C" to stop displaying the loading status update, then use "SHOW LOADING STATUS jobid" to track the loading progress again]
[Tip: Manage loading jobs with "ABORT/RESUME LOADING JOB jobid"]Startingthefollowingjob,i.e.JobName:load_social,jobid:social_m1.1528095850854Loadinglog:'/home/tigergraph/tigergraph/logs/restpp/restpp_loader_logs/social/social_m1.1528095850854.log'Job"social_m1.1528095850854"loadingstatus[FINISHED] m1 ( Finished:2/Total:2 ) [LOADED]+---------------------------------------------------------------------------+|FILENAME|LOADEDLINES|AVGSPEED|DURATION||/home/tigergraph/friendship.csv|8|8l/s|1.00s||/home/tigergraph/person.csv|8|7l/s|1.00s|+---------------------------------------------------------------------------+