15.1 Loading Graph Data from Files
You can load graph data from files by either of the two ways:
- using the header format specified in the files
- by directly calling the graph builder API
Creating a graph using file header format
The graph server (PGX) uses the header of the files to determine the name and types of the properties to load. It also infers the column to be used as vertex ID, the columns that indicate the source and destination vertex ID for edges, and the column to be loaded as vertex or edge label.
Creating a graph using graph builder API
You can also use PgxSession.readGraphFiles()
to load the graph. This method takes the following three arguments:
- path to the vertex file
- path to the edge file
- name of the graph to be created
Loading the Graph Data from a File Using JShell
opg4j> var loadedGraph = session.readGraphFiles("<path/vertices.csv>
", "<path/edges.csv>
", "<graph_name>
")
Loading the Graph Data from a File Using Java
import oracle.pgx.api.PgxSession;
import oracle.pgx.api.PgxGraph;
PgxSession session = Pgx.createSession("NewSession");
PgxGraph loadedGraph = session.readGraphFiles("<path/vertices.csv>
", "<path/edges.csv>
", "<graph_name>
")
Loading the Graph Data from a File Using Python
session = pypgx.get_session(session_name="<session_name>")
loaded_graph = session.read_graph_files("<path/vertices.csv>
", "<path/edges.csv>
", "<graph_name>
")
The graph server (PGX) supports loading graph data from files for the following data formats:
- Plain Text Formats
- XML File Formats
- Binary File Formats