csv_ops
Preview CSV files, convert CSV to XLSX, and export XLSX to CSV with configurable delimiters and encodings.
Instructions
CSV helper operations: preview CSV, convert CSV→XLSX, and export XLSX→CSV.
Args:
action: "preview", "to_xlsx", or "to_csv".
- "preview": requires file_path (CSV path); returns a small preview as dict.
- "to_xlsx": requires csv_path (or file_path) and xlsx_path (or output_path).
- "to_csv": requires file_path (XLSX) and output_path (CSV destination).
file_path, csv_path, xlsx_path, output_path: Path parameters as described above.
sheet_name: Sheet to export when converting XLSX→CSV.
rows: Number of preview rows to return.
delimiter, encoding: CSV parameters.
Returns: dict or str: Preview dict for "preview" or destination path for conversions.
Raises:
ValueError: If required path parameters are missing for the selected action.
Notes: - "to_xlsx" and "to_csv" perform file writes; document whether they overwrite existing files.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| rows | No | ||
| action | Yes | ||
| csv_path | No | ||
| encoding | No | utf-8 | |
| delimiter | No | , | |
| file_path | No | ||
| xlsx_path | No | ||
| sheet_name | No | Sheet1 | |
| output_path | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |