skills/ppt-station-skill/ppt_station/connectors/csv_connector.py
wangyitong a65adcc2e5 Initial commit: merged, deduplicated, and vetted skill collection
Sources: extracted from two upstream archives (skill-repo, skills-main),
merged with the following policy:

- 15 broken symlinks (pointing to /Users/jameslee/.cc-switch/skills or
  ../../.agents/skills on a foreign machine) discarded
- 3 real name collisions with identical content (ai-pair, ifind-http-api,
  zhipu-websearch) kept as one copy
- Functional overlaps deduped keeping the strongest variant:
  - docx family: kept docx (official, full toolchain) + docx-cn
    (GB/T 9704 Chinese official-document constants),
    dropped docx_writer (no scripts, name collided with docx)
  - humanizer family: kept humanizer-zh (6 zh reference docs),
    dropped humanizer (en, redundant for CN workflow)
- Skills that only ran in a foreign environment removed:
  ablemind-ops, app-publish, hlb-design-system, openclaw-adj-skill,
  claude-driver
- alphapai excluded from this public repo because its SKILL.md hard-coded
  live credentials

Result: 25 skills, 572 files, ~7.5 MB.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-13 14:47:12 +08:00

62 lines
1.9 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""
CSV 数据连接器
"""
import pandas as pd
from pathlib import Path
from ppt_station.connectors.base import BaseConnector, ConnectorFactory
from ppt_station.models.job import DataSource
from ppt_station.config import settings
class CsvConnector(BaseConnector):
"""CSV 文件连接器"""
def load(self, spec: DataSource) -> pd.DataFrame:
"""从 CSV 文件加载数据"""
if not spec.path:
raise ValueError("CSV connector requires 'path' parameter")
# 支持相对路径和绝对路径(相对路径优先 CWD回退 data_dir
file_path = Path(spec.path)
if not file_path.is_absolute():
cwd_path = Path.cwd() / file_path
if cwd_path.exists():
file_path = cwd_path
else:
file_path = settings.data_dir / file_path
if not file_path.exists():
raise FileNotFoundError(f"CSV file not found: {file_path}")
return pd.read_csv(file_path, encoding=spec.encoding or "utf-8")
class XlsxConnector(BaseConnector):
"""Excel 文件连接器"""
def load(self, spec: DataSource) -> pd.DataFrame:
"""从 Excel 文件加载数据"""
if not spec.path:
raise ValueError("XLSX connector requires 'path' parameter")
# 相对路径优先 CWD回退 data_dir
file_path = Path(spec.path)
if not file_path.is_absolute():
cwd_path = Path.cwd() / file_path
if cwd_path.exists():
file_path = cwd_path
else:
file_path = settings.data_dir / file_path
if not file_path.exists():
raise FileNotFoundError(f"Excel file not found: {file_path}")
return pd.read_excel(file_path, sheet_name=spec.sheet_name or 0)
# 注册连接器
ConnectorFactory.register("csv", CsvConnector)
ConnectorFactory.register("xlsx", XlsxConnector)