Introduction

In the DSH plugin ecosystem, processing CSV-format data files usually requires writing additional parsing logic. The xby-csv2 plugin provides direct conversion capability, mapping CSV data into JSON structures for easier subsequent data processing or API calls.

Plugin Positioning

This is an online tool plugin maintained by xby-skill, built on FastMCP, and primarily addresses the need for CSV-to-JSON format conversion.

Installation and Activation

Install the plugin using the following command:

dsh plugin --profile web add github:xby_skill/xby-csv2

After installation is complete, the plugin becomes active in the DSH process.

Core Features

1. Set API Key

set_xby_apikey
Set the API key in chat. The key is automatically persisted and remains valid after restart.

2. Retrieve File Information

get_csv_info
Retrieve basic information about a CSV file, including row count, column count, column names, etc., to assist conversion operations.

3. File Conversion

convert_csv_file
Convert a CSV file to a JSON file.

4. String Conversion

convert_csv_string
Convert CSV-formatted string content to JSON format.

Parameters and Usage

Taking convert_csv_file as an example, the main parameters are as follows:

  • file_path: Path to the CSV file. It must be a valid file path.
  • output_file_path: Output JSON file path (optional, defaults to a .json file with the same name as the CSV file in the same directory).
  • delimiter: CSV delimiter, defaults to a comma (,), with support for tabs, semicolons, etc.
  • encoding: File encoding, defaults to utf-8, with support for common encodings such as gbk and gb2312.
  • skip_rows: Number of rows to skip, defaults to 0, used to skip comments or blank lines at the beginning of the file.
  • header: Whether to include the header, defaults to True.
  • orient: JSON output format, defaults to “records” (a list of dictionary objects, one object per row). Other options include “values”, “split”, etc.
  • indent: JSON indentation, defaults to None (compact format).

Notes

  • Before use, obtain the API key from the official Xiaobenyang website.
  • Custom delimiters (such as tabs and semicolons) and multiple JSON output formats are supported.
  • Comments or blank lines at the beginning of a file can be skipped.
  • During invocation, it may raise FileNotFoundError (file not found), ValueError (format error), or Exception (other unknown errors).
  • GitHub Repository: https://github.com/xby_skill/xby-csv2
  • Plugin Catalog: https://www.skillhub.cn/plugins/xby-skill/xby-csv2