LOAD CSV reads rows from local or internet-accessible CSV files and exposes each row for later Cypher operations. Files may include headers or omit them: header rows produce map-like values, while headerless rows produce lists. Use FIELDTERMINATOR for custom delimiters. section 3.2.4
Use the clause with these practical considerations:
- Publicly accessible files can be fetched directly; LOAD CSV provides no authorization support. section 3.2.4
- All imported values arrive as strings, so convert identifiers, dates, and other values to suitable types in the import query. section 3.2.4
- Combine LOAD CSV with MERGE and ON CREATE SET to make imports handle duplicates more safely. section 3.2.5
- For larger files, use a Cypher subquery with IN TRANSACTIONS to divide work into batches and reduce memory pressure. section 3.2.5
Inspect the first rows
LOAD CSV WITH HEADERS FROM "https://example.org/users.csv" AS row WITH row LIMIT 5 RETURN row The same pattern supports graph imports: match existing nodes, merge new nodes or relationships, and convert values such as timestamps with datetime().
Listing 3.36 Cypher query that fetches and displays information from a CSV file
LOAD CSV WITH HEADERS FROM "https:/ /bit.ly/39JYakC" AS row WITH row LIMIT 5 RETURN row
Inspect a complete query that fetches a header-based CSV file, limits the preview to five rows, and returns each row. section 3.2.4
