Implementation:Explodinggradients Ragas LocalCSVBackend Class
Appearance
| Knowledge Sources | |
|---|---|
| Domains | Storage, Backend |
| Last Updated | 2026-02-10 00:00 GMT |
Overview
File-based storage backend using CSV format for local persistence of tabular datasets and experiments.
Description
LocalCSVBackend implements BaseBackend to store data as CSV files on the local filesystem. Datasets and experiments are saved to separate subdirectories under a configurable root directory. This backend is best suited for simple tabular data without deeply nested structures.
Usage
Use this backend when you need persistent local storage in a human-readable CSV format and your data is primarily flat/tabular.
Code Reference
Source Location
- Repository: Explodinggradients_Ragas
- File: src/ragas/backends/local_csv.py
- Lines: 12-146
Signature
class LocalCSVBackend(BaseBackend):
def __init__(self, root_dir: str) -> None:
...
Import
from ragas.backends.local_csv import LocalCSVBackend
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| root_dir | str | Yes | Root directory for CSV storage |
| name | str | Yes | Name of the dataset or experiment |
| data | List[Dict[str, Any]] | Yes | Records to save as CSV rows |
Outputs
| Name | Type | Description |
|---|---|---|
| load returns | List[Dict[str, Any]] | Records loaded from CSV (all values as strings) |
| list returns | List[str] | Sorted list of CSV file names (without extension) |
Usage Examples
from ragas.backends.local_csv import LocalCSVBackend
backend = LocalCSVBackend(root_dir="./my_data")
# Save a dataset
backend.save_dataset("eval_results", [
{"question": "What is AI?", "score": "0.85"},
{"question": "What is ML?", "score": "0.92"},
])
# Load the dataset
data = backend.load_dataset("eval_results")
print(data)
# List available datasets
print(backend.list_datasets()) # ["eval_results"]
Related Pages
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment