Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/neo4j-labs/neocarta/llms.txt

Use this file to discover all available pages before exploring further.

The CSV connector loads metadata into the Neo4j semantic graph from a directory of structured CSV files. It is useful when your data source doesn’t have a dedicated Neocarta connector, when you want to manually curate or augment metadata, or when migrating metadata from another tool. A sample e-commerce dataset is included in datasets/csv/ so you can test the connector immediately.

Import

from neocarta.connectors.csv import CSVConnector

Parameters

csv_directory
str
required
Filesystem path to the directory containing CSV files.
neo4j_driver
neo4j.Driver
required
Connected Neo4j driver instance.
database_name
str
default:"neo4j"
Target Neo4j database name.
csv_file_map
dict[str, str]
Optional mapping from NodeLabel / RelationshipType enum members (or their string values) to custom CSV filenames. Merges with the default filename map, allowing partial overrides. See Custom File Mapping below.

ingest() Parameters

include_nodes
list[NodeLabel]
Node types to load. When omitted, all available CSV files are loaded. Accepts NodeLabel enum members (recommended) or their exact string values, e.g. "Database".
include_relationships
list[RelationshipType]
Relationship types to load. When omitted, all available CSV files are loaded. Accepts RelationshipType enum members (recommended) or their exact string values, e.g. "HAS_SCHEMA".
CSV files that don’t exist on disk are skipped with a warning rather than raising an error, so you can start with a minimal set and add files incrementally.

Default CSV Filenames

The connector expects CSV files with the following default names. Any file can be renamed using csv_file_map.
CSV FileNode / Relationship
database_info.csvDatabase
schema_info.csvSchema
table_info.csvTable
column_info.csvColumn
column_references_info.csvREFERENCES
value_info.csvValue
query_info.csvQuery
query_table_info.csvUSES_TABLE
query_column_info.csvUSES_COLUMN
glossary_info.csvGlossary
category_info.csvCategory
business_term_info.csvBusinessTerm

ID Strategy

Entity IDs are computed from name columns using a dot-separated hierarchy. Choose one strategy and apply it consistently across all files.

Code Example

import os
from dotenv import load_dotenv
from neo4j import GraphDatabase
from neocarta import NodeLabel, RelationshipType
from neocarta.connectors.csv import CSVConnector

load_dotenv()

neo4j_driver = GraphDatabase.driver(
    uri=os.getenv("NEO4J_URI"),
    auth=(os.getenv("NEO4J_USERNAME"), os.getenv("NEO4J_PASSWORD")),
)
neo4j_database = os.getenv("NEO4J_DATABASE", "neo4j")

connector = CSVConnector(
    csv_directory="datasets/csv",
    neo4j_driver=neo4j_driver,
    database_name=neo4j_database,
)

# Load everything (all available CSV files)
connector.ingest()

Selective Ingest

Use include_nodes and include_relationships to load only a subset of the available data:
from neocarta import NodeLabel as nl, RelationshipType as rt

# Load core schema + query usage, skip glossary
connector.ingest(
    include_nodes=[
        nl.DATABASE,
        nl.SCHEMA,
        nl.TABLE,
        nl.COLUMN,
        nl.VALUE,
        nl.QUERY,
    ],
    include_relationships=[
        rt.HAS_SCHEMA,
        rt.HAS_TABLE,
        rt.HAS_COLUMN,
        rt.HAS_VALUE,
        rt.REFERENCES,
        rt.USES_TABLE,
        rt.USES_COLUMN,
    ],
)

neo4j_driver.close()
print("Connector completed successfully!")

Custom File Mapping

Configure custom filenames at construction time using csv_file_map. The map merges with the defaults, so you only need to specify the files you want to rename:
from neocarta import NodeLabel

custom_file_map = {
    NodeLabel.DATABASE: "my_databases.csv",
    NodeLabel.TABLE:    "my_tables.csv",
    NodeLabel.COLUMN:   "my_columns.csv",
}

connector = CSVConnector(
    csv_directory="path/to/my/data",
    neo4j_driver=neo4j_driver,
    database_name="neo4j",
    csv_file_map=custom_file_map,
)

connector.ingest()

CLI

pip install "neocarta[cli]"

neocarta csv ingest --csv-directory ./datasets/csv

Required Environment Variables

VariablePurpose
NEO4J_URINeo4j connection URI
NEO4J_USERNAMENeo4j username
NEO4J_PASSWORDNeo4j password
NEO4J_DATABASETarget Neo4j database (default: neo4j)
A ready-to-use sample e-commerce dataset lives in datasets/csv/. It demonstrates the full CSV structure — database, schema, tables, columns, foreign keys, sample values, query logs, and a business glossary — and can be used to test the connector without any external data source.

Build docs developers (and LLMs) love