|
| 1 | +--- |
| 2 | +title: Data Loader Example |
| 3 | +menuTitle: Example |
| 4 | +weight: 20 |
| 5 | +description: >- |
| 6 | + Follow this complete working example to see how easy it is to transform existing |
| 7 | + data into a graph and get insights from the connected entities |
| 8 | +archetype: default |
| 9 | +--- |
| 10 | + |
| 11 | +To transform your data into a graph, you need to have CSV files with entities |
| 12 | +representing the nodes and a corresponding CSV file representing the edges. |
| 13 | + |
| 14 | +This example uses a sample data set of two files, `airports.csv` and `flights.csv` |
| 15 | +to create a graph showing flights arriving to and departing from various cities. |
| 16 | + |
| 17 | +The `airports.csv` contains rows of airport entries, which are the future nodes |
| 18 | +in your graph. The `flights.csv` contains rows of flight entries, which are the |
| 19 | +future edges connecting the nodes. |
| 20 | + |
| 21 | +The whole process can be broken down into these steps: |
| 22 | + |
| 23 | +1. **Database and graph setup**: Begin by choosing an existing database or |
| 24 | + create a new one and enter a name for your new graph. |
| 25 | +2. **Add files**: Upload the CSV files to the Data Loader web interface. You can |
| 26 | + simply drag and drop them or upload them through the file browser window. |
| 27 | +3. **Design graph**: Design your graph schema by adding nodes and edges and map |
| 28 | + data from the uploaded files to them. This allows creating the corresponding |
| 29 | + documents and collections for your graph. |
| 30 | +4. **Import data**: Import the data and start using your newly created |
| 31 | + [EnterpriseGraph](../../graphs/enterprisegraphs/_index.md) and its |
| 32 | + corresponding collections. |
| 33 | + |
| 34 | +## Step 1: Create database and choose graph name |
| 35 | + |
| 36 | +Start by creating a new database and adding a name for your graph. |
| 37 | + |
| 38 | + |
| 39 | + |
| 40 | +## Step 2: Add files |
| 41 | + |
| 42 | +Upload your CSV files to the Data Loader web interface. You can drag and drop |
| 43 | +them or upload them via a file browser window. |
| 44 | + |
| 45 | + |
| 46 | + |
| 47 | +See also [Add files into Data Loader](../data-loader/add-files.md). |
| 48 | + |
| 49 | +## Step 3: Design graph schema |
| 50 | + |
| 51 | +Once the files are added, you can start designing the graph schema. This example |
| 52 | +uses a simple graph consisting of: |
| 53 | +- Two nodes (`origin_airport` and `destination_airport`) |
| 54 | +- One directed edge going from the origin airport to the destination one |
| 55 | + representing a flight |
| 56 | + |
| 57 | +Click **Add node** to create the nodes and connect them with edges. |
| 58 | + |
| 59 | +Next, for each of the nodes and edges, you need to create a mapping to the |
| 60 | +corresponding file and headers. |
| 61 | + |
| 62 | +For nodes, the **Node label** is going to be a node collection name and the |
| 63 | +**Primary identifier** will be used to populate the `_key` attribute of documents. |
| 64 | +You can also select any additional headers to be included as document attributes. |
| 65 | + |
| 66 | +In this example, two node collections have been created (`origin_airport` and |
| 67 | +`destination_airport`) and `AirportID` header is used to create the `_key` |
| 68 | +attribute for documents in both node collections. The header preview makes it |
| 69 | +easy to select the headers you want to use. |
| 70 | + |
| 71 | + |
| 72 | + |
| 73 | +For edges, the **Edge label** is going to be an edge collection name. Then, you |
| 74 | +need to specify how edges will connect nodes. You can do this by selecting the |
| 75 | +*from* and *to* nodes to give a direction to the edge. |
| 76 | +In this example, the `source airport` header has been selected as a source and |
| 77 | +the `destination airport` header as a target for the edge. |
| 78 | + |
| 79 | + |
| 80 | + |
| 81 | +Note that the values of source and target for the edge correspond to the |
| 82 | +**Primary identifier** (`_key` attribute) of the nodes. In this case, it is the |
| 83 | +airport code (i.e. GKA) used as the `_key` in the node documents and in the source |
| 84 | +and destination headers to configure the edges. |
| 85 | + |
| 86 | +See also [Design your graph in the Data Loader](../data-loader/design-graph.md). |
| 87 | + |
| 88 | +## Step 4: Import and see resulting graph |
| 89 | + |
| 90 | +After all the mapping is done, all you need to do is click |
| 91 | +**Save and start import**. The report provides an overview of the files |
| 92 | +processed and the documents created, as well as a link to your new graph. |
| 93 | +See also [Start import](../data-loader/import.md). |
| 94 | + |
| 95 | + |
| 96 | + |
| 97 | +Finally, click **See your new graph** to open the ArangoDB web interface and |
| 98 | +explore your new collections and graph. |
| 99 | + |
| 100 | + |
| 101 | + |
| 102 | +Happy graphing! |
0 commit comments