Import data¶
After CSV files of data and a schema are created, you can use the Import page to bulk import vertex and edge data into Nebula Graph for graph exploration and data analysis.
Prerequisites¶
To bulk import data, do a check of these:
- Studio is connected to Nebula Graph.
- A schema is created.
- CSV files for vertex and edge data separately are created.
- Your account has privileges of GOD, ADMIN, DBA, or USER.
Procedure¶
To bulk import data, follow these steps:
- In the toolbar, click the Import tab.
- On the Select Space page, choose a graph space name. In this example, mooc_actions is used. And then click the Next button.
- On the Upload Files page, click the Upload Files button and then choose CSV files. In this example,
user.csv
,course.csv
, andactions.csv
are chosen.NOTE: You can choose multiple CSV files at the same time.
- On the Select Files page, do a check of the file size and click Preview or Delete in the Operations column to make sure that all source data is correct. And then click the Next button.
- On the Map Vertices page, click the + Bind Datasource button, and in the dialog box, choose a CSV file. In this example,
user.csv
orcourse.csv
is chosen. - In the DataSource X tab, click the + Tag button.
-
In the vertexId section, do these operations: a. In the CSV Index column, click Mapping.
b. In the dialog box, choose a column from the CSV file. In this example, the only one cloumn ofuser.csv
is chosen to generate VIDs representing users and thecourseName
column ofcourse.csv
is chosen to generate VIDs representing courses.NOTE: VIDs are unique in one graph space. For more information about VIDs, see Vertex Identifier and Partition.
c. In the ID Hash column, choose how to generate VIDs. If the source data is of the
int
type, choose Original ID. If the source data is of thestring
,double
, orbool
type, choose Hash. -
In the TAG 1 section, do these operations:
a. In the TAG drop-down list, choose a tag name. In this example, user is used for theuser.csv
file, and course is used for thecourse.csv
file.
b. In the property list, click Mapping to choose a data column from the CSV file as the value of a property. In this example, the only column of theuser.csv
file is chosen to be the value of theuserId
property of theuser
tag. For the course tag, choose Column 0 for thecourseId
property and set its type to int, then choose Column 1 for thecourseName
property and set its type to string.
- (Optional) If necessary, repeat Step 5 through Step 8 for more tags.
- When the configuration is done, click the Next button.
When Config validation was successful prompts, data mapping for the vertices is successful. - On the Map Edges page, click the + Bind Datasource button, and in the dialog box, choose a CSV file. In this example, the
actions.csv
file is chosen. - In the Type drop-down list, choose an edge type name. In this example, action is chosen.
-
In the property list, click Mapping to choose a column from the
actions.csv
file as values of a property for the edges. srcId and dstId are the VIDs of the source vertex and destination vertex of an edge. The VID processing must be the same as that of the tag settings. In this example, srcId must be set to the VIDs of the users and dstId must be set to the VIDs of the courses. rank is optional. -
When the configuration is done, click the Next button.
- On the Import page, click the Start Import button. On the log window, you can see the import progress. The consumed time is related to the data volume. During data import, you can click the Stop Import button to stop data import. When the log window shows information as follows, the data import is done.
Next to do¶
When the data are imported to Nebula Graph, you can query graph data.