Source: https://dev-docs.nebula-graph.io/v5.3.2/analytic/algorithms/prepare-data/ Documentation version: v5.3.2 # Prepare algorithm sample data The algorithm examples import nodes and edges from CSV files. This page covers file preparation for a Docker Compose deployment. Each algorithm page provides the import statements and algorithm code. Before you start, [deploy the services](https://dev-docs.nebula-graph.io/v5.3.2/get-started/deploy/) and [sign in to NebulaGraph Studio](https://dev-docs.nebula-graph.io/v5.3.2/get-started/first-query/#connect). On the machine running Docker (the Docker host), open a terminal and go to the deployment directory containing `compose.yaml`. Run the Docker commands below in that terminal. ## 1. Check the directory mount The supplied [compose.yaml](https://dev-docs.nebula-graph.io/v5.3.2/get-started/files/compose.yaml) already includes this mount under `services.graphd.volumes`. If you deployed with this file, no change is needed: ```` volumes: - ./examples:/examples ```` `./examples` is a directory next to `compose.yaml` on the host, mounted at `/examples` inside the `graphd` container. Save the CSV files in this host directory so the Graph service can read them through the container path. You do not need to copy them into the container. Your existing compose.yaml is missing this mount Add `- ./examples:/examples` to `services.graphd.volumes`, keeping the other settings, then validate the configuration: ```` docker compose config --quiet ```` After validation succeeds, apply the configuration: ```` docker compose up -d graphd ```` This recreates the Graph container and removes its temporary graphs and their data. [Check the service status](https://dev-docs.nebula-graph.io/v5.3.2/get-started/deploy/#check-services), then reconnect in NebulaGraph Studio. ## 2. Download and save the CSV files The Prepare graph data section on each algorithm page provides CSV download links and a save location. The steps below use PageRank as an example: 1. Create an `examples/algorithms/pagerank` directory under your deployment directory. 2. Download [pagerank_node.csv](https://dev-docs.nebula-graph.io/v5.3.2/analytic/algorithms/files/pagerank/pagerank_node.csv) and [pagerank_edge.csv](https://dev-docs.nebula-graph.io/v5.3.2/analytic/algorithms/files/pagerank/pagerank_edge.csv) into it, keeping their original names and `.csv` extensions. After saving the files, your directory should look like this: ```` dev-quickstart/ ├── compose.yaml └── examples/ └── algorithms/ └── pagerank/ ├── pagerank_node.csv └── pagerank_edge.csv ```` If the files are saved to the browser's default download folder, move them to the location above. If the browser displays the CSV contents, use “Save As” to save the file. For other algorithms, use the directory and files specified on their page. If Docker runs on a remote server, save the files under the deployment directory on that server. ## 3. Check the files and run the algorithm In the host terminal, run this command to check that the container can see the PageRank CSV files: ```` docker compose exec graphd ls -1 /examples/algorithms/pagerank/ ```` The output should include `pagerank_node.csv` and `pagerank_edge.csv`. To check another algorithm, replace `pagerank` in the command with its directory name. Once the files are visible, return to [PageRank](https://dev-docs.nebula-graph.io/v5.3.2/analytic/algorithms/pagerank/#1_prepare_graph_data) or your chosen algorithm page. In the NebulaGraph Studio CONSOLE, use the default Schema (`/default_schema`) and run that page's examples in order. Wait for each code block to succeed before continuing. Run again or change the data If you only change algorithm parameters, call the procedure again. Editing a CSV does not automatically update the temporary graph. Before reloading, drop the original temporary graph and its data. For PageRank, run this in the NebulaGraph Studio console. For other algorithms, use their temporary graph name: ```` DROP GRAPH IF EXISTS #pagerank_graph ```` Follow the algorithm page to recreate the temporary graph, import the data, check the node count, and call the procedure again. After restarting the Graph service, also recreate the temporary graph and import the data. Run the examples with ngql Follow the [ngql connection instructions](https://dev-docs.nebula-graph.io/v5.3.2/get-started/first-query/#ngql) to sign in, then run the GQL examples from the algorithm page. Multiline examples already include `'''` on its own line at the start and end. Include both lines when copying; do not add another pair. Enter the closing `'''` and press Enter to submit the statement. See the [ngql usage guide](https://dev-docs.nebula-graph.io/v5.3.2/utilities/ngql/usage/). ## 4. View the results Follow the Call your procedure section on the algorithm page to view results: - Tables: View them in the NebulaGraph Studio query results area. - CSV files: Open the host directory specified on the algorithm page. For example, PageRank results are saved to `examples/algorithms/pagerank/output/` under your deployment directory. The export creates the result directory automatically and generates the filenames. One run can produce multiple CSV files; use modification times to find the current results. Without `ORDER BY`, result rows can appear in a different order from the example. Compare column names and values when checking the output. ## Troubleshoot file access | Problem | What to check | A file is not found | Check the [save location and filenames](https://dev-docs.nebula-graph.io/v5.3.2/analytic/algorithms/prepare-data/#download), then [check the files in the container](https://dev-docs.nebula-graph.io/v5.3.2/analytic/algorithms/prepare-data/#run). If they are not visible, check the [directory mount](https://dev-docs.nebula-graph.io/v5.3.2/analytic/algorithms/prepare-data/#mount). | A permission error occurs | Check the host examples directory and CSV file permissions. The Graph service needs to read the input files and write to the result directory. | Import reports `Import to non-empty graph` | The temporary graph already contains data. Skip the import to continue using it, or [reload the data](https://dev-docs.nebula-graph.io/v5.3.2/analytic/algorithms/prepare-data/#reload) to use new files. | A call reports that the procedure does not exist | First run the required procedure definitions on the algorithm page successfully. Use the same Schema for the definitions and the call.