LOAD CSV FROM accepts a string path to a CSV file. The file is parsed line by line, and the current line is accessible through the variable specified by AS. Each parsed value is treated as a string. Use appropriate conversion functions, for example, toInteger, to cast values to their correct types.
Additional clauses can follow and access the row variable.
Additional clauses can follow and accesses the row variable
FIELD DELIMITER
If not specified, ’,’ is used as the default field delimiter. To change the delimiter, use the following:IMPORTING DATA
Importing local files
FalkorDB defines a data directory see configuration Under which local CSV files should be stored. Allfile:// URIs are resolved
relative to that directory.
In the following example we’ll load the actors.csv file into FalkorDB.
actors.csv
row[0] to access the value at the corresponding
column.
If the CSV contains a header row, like this:
actors.csv
Use the
WITH HEADERS variation of the LOAD CSV clause:
WITH HEADERS is specified, the row variable becomes a map instead of an array. Access individual elements via their column names.
Importing data from multiple CSVs
Building on the previous example, we’ll introduce a second CSV file,acted_in.csv, which connects actors to movies.
acted_in.csv
We’ll create a new graph connecting actors to the movies they’ve acted in
Load actors:
ACTED_IN relations:
Importing remote files
FalkorDB supports importing remote CSVs via HTTPS. Here’s an example loading the Big Mac dataset from calmcode.io:Dealing with a large number of columns or missing entries
Loading CSV files with missing entries can cause complications. The following approach handles this and works well for files with many columns. Assuming we are loading the following CSV file:missing_entries.csv
Note: Vin Diesel and Chris Pratt are missing their birth_year entries.
When creating Actor nodes, there is no need to explicitly define each column as done previously.
The following query creates an empty Actor node and assigns the current CSV row to it.
This process automatically sets the node’s attribute set to match the values of the current row:
Frequently Asked Questions
Where should I place CSV files for import?
Where should I place CSV files for import?
Local CSV files should be placed in the configured data directory (see the
IMPORT_FOLDER configuration setting). All file:// URIs are resolved relative to that directory.How do I import a CSV with headers?
How do I import a CSV with headers?
Use
LOAD CSV WITH HEADERS FROM 'file://data.csv' AS row — this makes row a map where you access columns by name (e.g. row['name']) instead of by index.Can I import CSV files from remote URLs?
Can I import CSV files from remote URLs?
Yes. FalkorDB supports importing via HTTPS:
LOAD CSV FROM 'https://example.com/data.csv' AS row. Only HTTPS URLs are supported for remote imports.How do I handle different column delimiters?
How do I handle different column delimiters?
Use the
FIELDTERMINATOR option: LOAD CSV FROM 'file://data.csv' AS row FIELDTERMINATOR ';'. The default delimiter is a comma.Are all CSV values loaded as strings?
Are all CSV values loaded as strings?
Yes. All parsed values are treated as strings. Use conversion functions like
toInteger(), toFloat(), or toBoolean() to cast values to their correct types.