import_rows
Import rows from a CSV or JSON file into a dataset with a two-step process: preview the column mapping, then confirm to add valid rows and receive clear rejection reasons for invalid ones.
Instructions
Import rows into a dataset from a CSV or JSON file, in two safe steps.
Step 1 (confirm=false, default): returns a mapping preview - how each file column maps to a dataset column, unmatched file columns, missing required dataset columns, and a small sample. Share the mapping with the user and let them confirm or adjust the file.
Step 2 (confirm=true): imports. Every row is validated against the dataset schema; valid rows are added and invalid rows are reported with plain-language reasons. CSV values are coerced automatically ("5" becomes the number 5, "true" becomes a boolean).
Args: dataset: Exact dataset name, e.g. "Candidates". file_path: Path to the .csv or .json file on this machine. format: "auto" (default, infers from extension), or force "csv"/"json". confirm: Must be true to actually import (default false = preview only). create_if_missing: When the dataset does not exist, create it first with one string column per file header, then import (default false).
Returns: Preview: {"ok": true, "requires_confirmation": true, "preview": {...}}. Commit: {"ok": true, "dataset", "added": , "rejected": , "rejected_rows": [{"row": , "errors": ["..."]}]}.
Example: import_rows(dataset="Candidates", file_path="~/Downloads/applicants.csv")
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| format | No | auto | |
| confirm | No | ||
| dataset | Yes | ||
| file_path | Yes | ||
| create_if_missing | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||