Communitygithub.com

baronguyen001/ai-automation-skills

将一次运行的结果字典列表转换为带模式的 CSV 和 Markdown 表格,只需一次列定义即可同时输出,列序稳定,安全转义,仅依赖标准库,无需 pandas。当用户要求写入 CSV、导出报告、生成 Markdown 摘要表格或保存运行输出为电子表格时使用。

ai-automation-skills 是什么?

本技能通过单一列定义,同时生成结构化的 CSV 文件和 Markdown 表格。每次作业产生结果行列表时,只需声明一次列(包括键名、表头、可选格式化函数),即可获得列序稳定、CSV 正确引用和 Markdown 管道符转义的两种输出,确保两者永不漂移。它仅依赖 Python 标准库的 csv 模块,无需 pandas 或 polars 等第三方库,特别适合需要快速导出数据到电子表格或嵌入 PR 评论、Telegram 摘要的场景。支持 Cursor、Claude 等所有主流 AI 开发工具,通过 assets/report.py 中的三个函数(Column、write_csv、to_markdown)实现。当数据需要复杂的数据框操作(如连接、分组、透视)时,建议改用 pandas/polars;对于单一标量结果,则无需使用此技能。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/baronguyen001/ai-automation-skills/tree/HEAD/skills/csv-report-writer

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

CSV 报告写入器

当作业产生结果行列表,并且你需要一份整洁的 CSV(用于电子表格)以及用于 PR 评论或 Telegram 摘要的 Markdown 表格时,请使用此技能——只需一次列定义,两种输出永远不会不一致。你只需声明一次列(键、表头、可选的格式化函数);辅助函数将同时生成两种输出,列序稳定,CSV 引用正确,Markdown 管道符已转义。无需 pandas。

何时调用

  • 用户说:“将结果写入 CSV”、“导出报告”、“生成此数据的 Markdown 表格”、“将运行输出保存为电子表格”。
  • 对话中的代码有一个 list[dict](或对象列表)当前以临时方式打印。

何时不调用

  • 数据需要进行真正的数据框操作——连接、分组、透视;此时请使用 pandas/polars。
  • 结果为单一标量,使用 CSV/表格过于冗余。

具体示例

用户输入:

我有一个扫描的令牌列表,包含分数和价格。请保存 CSV,并提供一个 Markdown 表格用于 Telegram 摘要。

输出:

# 将 assets/report.py 复制到你的项目中,然后:
from report import Column, write_csv, to_markdown

columns = [
    Column("symbol", "Symbol"),
    Column("score", "Score", fmt=lambda v: f"{v:.1f}"),
    Column("price_usd", "Price", fmt=lambda v: f"${v:,.4f}"),
]
rows = [
    {"symbol": "ABC", "score": 8.4, "price_usd": 0.0123},
    {"symbol": "XYZ", "score": 6.1, "price_usd": 1.5},
]

write_csv("scan.csv", columns, rows)        # 带模式的 CSV,列序稳定
print(to_markdown(columns, rows))           # 相同列,Markdown 表格

两种输出使用完全相同的列,顺序也完全相同,因此 CSV 和摘要表格始终一致。

应用模式

  1. 每个 Column(key, header, fmt=...) 只声明一次;两个写入器都消费同一个列表,因此表头和顺序保持同步。
  2. 保持列序稳定且显式——不要依赖任意行的字典插入顺序。
  3. 让 fmt 可调用对象负责呈现(货币、舍入);在行字典中存储原始值。
  4. 使用 csv.writer 进行正确的引用;对 Markdown 表格中的 | 和换行符进行转义,使其永远不会破坏布局。
  5. 将缺失的键视为空单元格而不是崩溃,这样部分行仍然可以报告。

参考:assets/report.py。

来源

从作者自动化项目的生产使用中提炼。v1.0.0。 另见:[[pr-body-formatter]]、[[sqlite-state]]、[[telegram-alerter]]。

→ 使用 Trawlkit 构建完整的可运行机器人。

Individual skills in this repo

This repo contains 9 individual skills — each has its own dedicated page.

baronguyen001/ai-automation-skills

Schedule any script to run on a recurring schedule on Windows (Task Scheduler) or Linux (cron) - register, list, and remove jobs from one command, with logging to a file and a guard against overlapping runs. Use for schedule a script, run nightly, set up a cron job, windows task scheduler, or run on a timer.

baronguyen001/ai-automation-skills

Strip HTML to clean plain text with the standard library only (no BeautifulSoup/lxml): drops script/style, turns block tags into line breaks, and collapses whitespace. Use when the user wants readable text from an HTML page/email, to clean scraped HTML before sending it to an LLM, or to build a text index from web content.

baronguyen001/ai-automation-skills

Persist records between scheduled runs as append-only JSON Lines (one object per line) with streaming reads and optional key-based dedup, stdlib only. Use when the user wants to log run results to JSONL, append events to a file, dedup records by id across runs, or keep a simple durable history without a database.

baronguyen001/ai-automation-skills

Extract text and simple table-like rows from a PDF for downstream AI without OCR binaries. Use when the user asks to read a PDF, turn a PDF into text, pull simple tables from statements/reports, or feed PDF content into an LLM pipeline.

baronguyen001/ai-automation-skills

Rotate a pool of HTTP/SOCKS proxies with round-robin selection, failure tracking, and a cooldown that benches dead proxies before retrying. BYO proxy list via env - none are shipped. Use for rotate proxies, spread requests across proxies, avoid IP bans, retry through a different proxy, or proxy health check.

baronguyen001/ai-automation-skills

Parse an RSS 2.0 or Atom feed into normalized item dicts (title, link, id, published, summary) with the standard library only - no feedparser. Use when the user asks to read an RSS/Atom feed, poll a blog/news feed, extract feed entries, or watch a site that publishes a feed.

baronguyen001/ai-automation-skills

Upload and download run artifacts from S3-compatible storage with BYO bucket and credentials from env. Use when the user asks to store scraper output, archive reports, publish artifacts to object storage, fetch a prior run file, or use MinIO/R2/Spaces/S3 without hardcoding credentials.

baronguyen001/ai-automation-skills

Draft a short-form TikTok/Reels/Shorts or long-form video script from a topic and creator persona file - hook variants, beat-structured body, CTA, b-roll cues, caption overlays, and [STORY]/[NUMBER] slots so the model never fabricates personal facts. Use for write a video script, tiktok script, youtube script, or /shortform-script.

baronguyen001/ai-automation-skills

Give scheduled scripts memory between runs with one SQLite file - a seen-set for dedup, a key/value cursor to resume where you left off, and order-preserving new-item filtering. Use for dedup across runs, don't re-alert the same item, remember the last id, resume a scraper, or persist state between cron runs.

相关技能