convert-file
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseYou are helping the user convert a data file from one format to another using DuckDB.
Input file:
Output file:
$0${1:-}你将协助用户使用DuckDB将数据文件从一种格式转换为另一种格式。
输入文件:
输出文件:
$0${1:-}Step 1 — Resolve input and output
步骤1 — 解析输入与输出
Input: . If it's a bare filename (no ), resolve to a full path with .
$0/find "$PWD" -name "$0" -not -path '*/.git/*' 2>/dev/null | head -1Output: If is provided, use it as the output path. If not, default to the same stem as the input with a extension (e.g., → ).
$1.parquetdata.csvdata.parquetInfer the output format from the output file extension:
| Extension | Format clause |
|---|---|
| (default, no clause needed) |
| |
| |
| |
| |
| |
| |
| |
| |
输入:。如果是纯文件名(无),使用解析为完整路径。
$0/find "$PWD" -name "$0" -not -path '*/.git/*' 2>/dev/null | head -1输出:如果提供了,则将其作为输出路径。如果未提供,默认使用与输入文件相同的文件名前缀,后缀改为(例如: → )。
$1.parquetdata.csvdata.parquet根据输出文件的扩展名推断输出格式:
| 扩展名 | 格式子句 |
|---|---|
| (默认,无需子句) |
| |
| |
| |
| |
| |
| |
| |
| |
Step 2 — Convert
步骤2 — 执行转换
Run a single DuckDB command. Prepend extension loads as needed based on both the input and output formats.
bash
duckdb -c "
<EXTENSION_LOADS>
COPY (FROM '<INPUT_PATH>') TO '<OUTPUT_PATH>' <FORMAT_CLAUSE>;
"For remote inputs (, , etc.), prepend the same protocol setup as :
s3://https://read-file| Protocol | Prepend |
|---|---|
| |
| |
| |
If the user mentions partitioning (e.g., "partition by year"), add to the format clause. This only works with Parquet and CSV output.
PARTITION_BY (col)If the user mentions compression (e.g., "use zstd"), add for Parquet output.
CODEC 'zstd'运行单个DuckDB命令。根据输入和输出格式的需要,预先加载对应的扩展。
bash
duckdb -c "
<EXTENSION_LOADS>
COPY (FROM '<INPUT_PATH>') TO '<OUTPUT_PATH>' <FORMAT_CLAUSE>;
"对于远程输入(如、等),预先添加与相同的协议配置:
s3://https://read-file| 协议 | 预添加内容 |
|---|---|
| |
| |
| |
如果用户提及分区(例如:“按年份分区”),在格式子句中添加。此功能仅适用于Parquet和CSV输出格式。
PARTITION_BY (col)如果用户提及压缩(例如:“使用zstd”),对于Parquet输出,添加。
CODEC 'zstd'Step 3 — Report
步骤3 — 结果报告
On success, report:
- Input file and detected format
- Output file, format, and size ()
ls -lh - Row count if quick to compute
On failure:
- → delegate to
duckdb: command not found/duckdb-skills:install-duckdb - Missing extension → install it and retry
- Input parse error → suggest the user check the input format or try first to inspect it
/duckdb-skills:read-file
转换成功时,报告以下内容:
- 输入文件及其检测到的格式
- 输出文件、格式及大小(使用命令获取)
ls -lh - 如果可快速计算,还需报告行数
转换失败时:
- → 调用
duckdb: command not found进行处理/duckdb-skills:install-duckdb - 缺少扩展 → 安装对应扩展并重试
- 输入解析错误 → 建议用户检查输入格式,或先使用工具查看文件内容
/duckdb-skills:read-file