Import data into NebulaGraph Cloud¶
This topic introduces how to import data into NebulaGraph Cloud.
Prerequisites¶
- A graph type and a graph are created. For more information, see Import custom data.
- Step 1 to 3 in the NebulaGraph Cloud quickstart guide are completed. For more information, see quickstart guide.
Create an import task¶
On the left-side navigation pane of the database details page, click Import > Import Data to create an import task, which includes uploading files, configuring files, and mapping data.
Step 1 Upload files¶
-
In the top left corner, select a graph from the Load to Graph dropdown menu for data import.
-
On the Upload files tab, choose one of the following data sources to upload data, then click Next.
- Local file: Upload CSV files from your local machine.
- Amazon S3: Click +Add, enter your Amazon S3 URL and click Connect. You can add up to 10 Amazon S3 URLs. Only CSV files are supported.
(Optional) Step 2 Configure files¶
If your CSV files do not contain headers, click Next to skip this step.
- On the Configure files tab, check the uploaded data files.
- In the top right corner of each file, click and select the With header checkbox to exclude headers from mapping.
- Click Apply to all files to exclude headers in all your uploaded files.
- Click Next.
Step 3 Map data¶
-
On the Mapping tab, specify the following items:
- Type: Select a node type or edge type you created before.
- Select a file: Select an uploaded file.
-
Map from file or Direction: Map data from specified columns to graph type properties using the following methods.
- To map data individually, select each column name from the file.
- To map data in batches, click Quick Mapping on the right side. If the column name match the property name, the system maps them automatically. If they do not match, the system maps them sequentially.
-
Click Next and check the mapping information on the Check & Run page.
-
Click Import to start the import task and view the task state on the Import page.
For a detailed example about mapping, see Best practice for mapping.
Manage import tasks¶
- On the left-side navigation pane of the database details page, click Import.
-
On the Import page, you can view and manage the import tasks. The task list includes:
- ID: The import task ID
- Graph: The graph where the data is imported
- States: The states of the import task, including Running, Completed, and Failed. If errors appear, click Logs in this column to troubleshoot.
- Size: The size of the imported data
- Loaded lines: The number of lines loaded from files
- Created at: The time when the import task was created
- Duration: The time taken to complete the import task
- Actions: To delete an import task, click Delete in this column.
Best practice for mapping¶
To show you a best practice for mapping in NebulaGraph Cloud, we take the following local files and graph types of the demo dataset as an example.
Local file to be imported | Graph type name | Property |
---|---|---|
sub_user.csv : Contains the information about users. |
User | id |
sub_movie.csv : Contains the information about movies. |
Movie | id and name |
sub_user_watched_movies.csv : Contains the information about the relationship between users and movies. |
Watch | rate |
Before you start, make sure:
- Files above are downloaded. You can click file names above to download files.
- The node types
User
andMovie
, the edge typeWatch
, and the graphmovie
are created according to the demo dataset. For more information, see Create a graph type and Create a graph. - step 1 and step 2 are completed.
Follow the steps below to map the data in sub_user.csv
, sub_movie.csv
, and sub_user_watched_movies.csv
to the node types User
and Movie
, and the edge type Watch
, respectively.
-
In the top left corner of the Import page, select the graph
movie
from the Load to Graph dropdown menu. -
On the Mapping tab, specify the items according to the table and click Confirm:
Type Select a file Direction Map from file User sub_use.csv NA Property: id ⬅ Column name: user_id(187) Movie sub_movie.csv NA Property: id ⬅ Column name: movie_id(4)
Property: name ⬅ Column name: name(Estado De Sitio)Watch sub_user_watched_movies.csv Property: id ⬅ Column name: user_id(187)
Property: name ⬅ Column name: movie_id(1)Property: rate ⬅ Column name: rate(3.5) Note
The first row of imported data is displayed in the parentheses
()
next to the column name. -
Click Next once you have mapped all the data.
-
Check the mapping information on the Check & Run page and click Import.