npx skills add https://github.com/dglowacki/mega-agent-v2 --skill data-aggregation用于聚合、转换和合并来自多个来源数据的工具。
聚合 App Store 销售数据:
python scripts/aggregate_sales.py --input sales_reports/ --output aggregated.json
聚合 GitHub 提交记录:
python scripts/aggregate_commits.py --input commits.json --period week --output summary.json
合并多个数据源:
python scripts/merge_sources.py --sources app_store.json github.json skillz.json --output combined.json
按时间段(日、周、月)分组数据。
示例:每日销售总额
from aggregate_sales import aggregate_by_time
# 输入:销售记录列表
sales = [
{"date": "2026-01-14", "revenue": 123.45, "units": 5},
{"date": "2026-01-14", "revenue": 67.89, "units": 3},
{"date": "2026-01-15", "revenue": 234.56, "units": 8}
]
# 输出:按日聚合
result = aggregate_by_time(sales, period='day')
# {
# "2026-01-14": {"revenue": 191.34, "units": 8},
# "2026-01-15": {"revenue": 234.56, "units": 8}
# }
Tools for aggregating, transforming, and merging data from multiple sources.
Aggregate App Store sales:
python scripts/aggregate_sales.py --input sales_reports/ --output aggregated.json
Aggregate GitHub commits:
python scripts/aggregate_commits.py --input commits.json --period week --output summary.json
Merge multiple sources:
python scripts/merge_sources.py --sources app_store.json github.json skillz.json --output combined.json
Group data by time periods (day, week, month).
Example: Daily sales totals
from aggregate_sales import aggregate_by_time
# Input: List of sales records
sales = [
{"date": "2026-01-14", "revenue": 123.45, "units": 5},
{"date": "2026-01-14", "revenue": 67.89, "units": 3},
{"date": "2026-01-15", "revenue": 234.56, "units": 8}
]
# Output: Aggregated by day
result = aggregate_by_time(sales, period='day')
# {
# "2026-01-14": {"revenue": 191.34, "units": 8},
# "2026-01-15": {"revenue": 234.56, "units": 8}
# }
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
按实体(应用、用户、仓库等)分组数据。
示例:每个应用的指标
from aggregate_sales import aggregate_by_entity
sales = [
{"app": "App A", "revenue": 100, "units": 5},
{"app": "App A", "revenue": 50, "units": 2},
{"app": "App B", "revenue": 200, "units": 10}
]
result = aggregate_by_entity(sales, entity_field='app')
# {
# "App A": {"revenue": 150, "units": 7},
# "App B": {"revenue": 200, "units": 10}
# }
计算统计信息(总和、平均值、最小值、最大值、百分位数)。
示例:提交统计
from aggregate_commits import calculate_stats
commits = [
{"author": "John", "lines": 125},
{"author": "Jane", "lines": 87},
{"author": "John", "lines": 43}
]
result = calculate_stats(commits, group_by='author', metric='lines')
# {
# "John": {"sum": 168, "avg": 84, "min": 43, "max": 125, "count": 2},
# "Jane": {"sum": 87, "avg": 87, "min": 87, "max": 87, "count": 1}
# }
输入格式(来自 App Store Connect 的 TSV 文件):
Provider Provider Country SKU Developer Title Version Product Type Identifier Units Developer Proceeds Begin Date End Date Customer Currency Country Code Currency of Proceeds Apple Identifier Customer Price Promo Code Parent Identifier Subscription Period Category CMB Device Supported Platforms Proceeds Reason Preserved Pricing Client
聚合输出:
{
"period": "2026-01-14",
"apps": {
"com.example.app": {
"name": "My App",
"downloads": 1234,
"revenue": 567.89,
"updates": 45,
"countries": ["US", "CA", "UK"]
}
},
"totals": {
"total_downloads": 5678,
"total_revenue": 2345.67,
"total_apps": 5
}
}
输入格式(来自 GitHub API):
[
{
"sha": "abc123",
"author": {"name": "John Doe", "email": "john@example.com"},
"commit": {
"message": "Add feature X",
"author": {"date": "2026-01-14T10:30:00Z"}
},
"stats": {"additions": 125, "deletions": 45}
}
]
聚合输出:
{
"period": "week",
"date_range": "2026-01-07 to 2026-01-14",
"summary": {
"total_commits": 45,
"total_contributors": 5,
"total_lines": 2345,
"total_files": 123
},
"by_author": {
"John Doe": {
"commits": 15,
"lines_added": 1234,
"lines_deleted": 456,
"files_changed": 45
}
},
"by_day": {
"2026-01-14": {"commits": 8, "lines": 567}
}
}
输入格式(来自 Skillz 开发者门户):
{
"event_id": "888831",
"name": "Winter Tournament",
"status": "active",
"start_date": "2026-01-10",
"end_date": "2026-01-20",
"prize_pool": 1000,
"entries": 234
}
聚合输出:
{
"period": "active",
"summary": {
"total_events": 8,
"total_prize_pool": 8000,
"total_entries": 1234
},
"by_status": {
"active": {"count": 5, "prize_pool": 5000},
"completed": {"count": 3, "prize_pool": 3000}
}
}
聚合 App Store 销售数据。
用法:
python scripts/aggregate_sales.py \
--input sales_reports/ \
--period week \
--group-by app \
--output aggregated.json
参数:
--input:输入目录或文件(TSV/JSON)--period:时间段(day, week, month)--group-by:分组字段(app, country, category)--output:输出 JSON 文件聚合 GitHub 提交数据。
用法:
python scripts/aggregate_commits.py \
--input commits.json \
--period week \
--metrics lines,files,commits \
--output summary.json
参数:
--input:输入 JSON 文件(提交数组)--period:时间段(day, week, month)--metrics:要计算的指标(逗号分隔)--output:输出 JSON 文件聚合 Skillz 事件数据。
用法:
python scripts/aggregate_events.py \
--input events/ \
--status active,completed \
--output summary.json
参数:
--input:包含事件 JSON 文件的输入目录--status:按状态筛选(逗号分隔)--output:输出 JSON 文件合并来自多个数据源的数据。
用法:
python scripts/merge_sources.py \
--sources app_store.json github.json skillz.json \
--strategy combine \
--output combined.json
参数:
--sources:JSON 文件列表(空格分隔)--strategy:合并策略(combine, average, latest)--output:输出 JSON 文件合并策略:
combine:合并所有数据(保留所有字段)average:对数值字段取平均值latest:保留最新值(按时间戳)from aggregate_sales import filter_data
sales = [...]
# 按国家筛选
us_sales = filter_data(sales, country='US')
# 按日期范围筛选
recent_sales = filter_data(sales, start_date='2026-01-01', end_date='2026-01-14')
# 按值筛选
high_revenue = filter_data(sales, min_revenue=100)
from aggregate_commits import group_data
commits = [...]
# 按作者分组
by_author = group_data(commits, group_by='author')
# 按仓库分组
by_repo = group_data(commits, group_by='repository')
# 按日期分组
by_date = group_data(commits, group_by='date', period='day')
from merge_sources import sort_data
data = [...]
# 按收入排序(降序)
sorted_data = sort_data(data, field='revenue', reverse=True)
# 按日期排序(升序)
sorted_data = sort_data(data, field='date')
# 聚合 App Store 销售数据
from aggregate_sales import aggregate_sales
sales_data = appstore_client.get_sales_report(days=7)
aggregated = aggregate_sales(sales_data, period='day', group_by='app')
# 用于报告
html = render_template('appstore-metrics', aggregated)
# 聚合 GitHub 提交记录
from aggregate_commits import aggregate_commits
commits = github_client.get_commits(repo='owner/repo', days=7)
summary = aggregate_commits(commits, period='week')
# 如果活动量高,则创建 ClickUp 任务
if summary['total_commits'] > 50:
clickup_client.create_task(
title='High GitHub Activity',
description=f"Total commits: {summary['total_commits']}"
)
查看 examples/ 目录:
sample_sales_aggregation.json - App Store 销售示例sample_commit_aggregation.json - GitHub 提交示例sample_multi_source_merge.json - 多源合并示例每周安装次数
1
仓库
首次发现
1 天前
安全审计
安装于
zencoder1
amp1
cline1
openclaw1
opencode1
cursor1
Group data by entities (apps, users, repos, etc.).
Example: Per-app metrics
from aggregate_sales import aggregate_by_entity
sales = [
{"app": "App A", "revenue": 100, "units": 5},
{"app": "App A", "revenue": 50, "units": 2},
{"app": "App B", "revenue": 200, "units": 10}
]
result = aggregate_by_entity(sales, entity_field='app')
# {
# "App A": {"revenue": 150, "units": 7},
# "App B": {"revenue": 200, "units": 10}
# }
Calculate statistics (sum, avg, min, max, percentiles).
Example: Commit statistics
from aggregate_commits import calculate_stats
commits = [
{"author": "John", "lines": 125},
{"author": "Jane", "lines": 87},
{"author": "John", "lines": 43}
]
result = calculate_stats(commits, group_by='author', metric='lines')
# {
# "John": {"sum": 168, "avg": 84, "min": 43, "max": 125, "count": 2},
# "Jane": {"sum": 87, "avg": 87, "min": 87, "max": 87, "count": 1}
# }
Input format (TSV from App Store Connect):
Provider Provider Country SKU Developer Title Version Product Type Identifier Units Developer Proceeds Begin Date End Date Customer Currency Country Code Currency of Proceeds Apple Identifier Customer Price Promo Code Parent Identifier Subscription Period Category CMB Device Supported Platforms Proceeds Reason Preserved Pricing Client
Aggregated output:
{
"period": "2026-01-14",
"apps": {
"com.example.app": {
"name": "My App",
"downloads": 1234,
"revenue": 567.89,
"updates": 45,
"countries": ["US", "CA", "UK"]
}
},
"totals": {
"total_downloads": 5678,
"total_revenue": 2345.67,
"total_apps": 5
}
}
Input format (from GitHub API):
[
{
"sha": "abc123",
"author": {"name": "John Doe", "email": "john@example.com"},
"commit": {
"message": "Add feature X",
"author": {"date": "2026-01-14T10:30:00Z"}
},
"stats": {"additions": 125, "deletions": 45}
}
]
Aggregated output:
{
"period": "week",
"date_range": "2026-01-07 to 2026-01-14",
"summary": {
"total_commits": 45,
"total_contributors": 5,
"total_lines": 2345,
"total_files": 123
},
"by_author": {
"John Doe": {
"commits": 15,
"lines_added": 1234,
"lines_deleted": 456,
"files_changed": 45
}
},
"by_day": {
"2026-01-14": {"commits": 8, "lines": 567}
}
}
Input format (from Skillz Developer Portal):
{
"event_id": "888831",
"name": "Winter Tournament",
"status": "active",
"start_date": "2026-01-10",
"end_date": "2026-01-20",
"prize_pool": 1000,
"entries": 234
}
Aggregated output:
{
"period": "active",
"summary": {
"total_events": 8,
"total_prize_pool": 8000,
"total_entries": 1234
},
"by_status": {
"active": {"count": 5, "prize_pool": 5000},
"completed": {"count": 3, "prize_pool": 3000}
}
}
Aggregate App Store sales data.
Usage:
python scripts/aggregate_sales.py \
--input sales_reports/ \
--period week \
--group-by app \
--output aggregated.json
Arguments:
--input: Input directory or file (TSV/JSON)--period: Time period (day, week, month)--group-by: Grouping field (app, country, category)--output: Output JSON fileAggregate GitHub commit data.
Usage:
python scripts/aggregate_commits.py \
--input commits.json \
--period week \
--metrics lines,files,commits \
--output summary.json
Arguments:
--input: Input JSON file (commits array)--period: Time period (day, week, month)--metrics: Metrics to calculate (comma-separated)--output: Output JSON fileAggregate Skillz event data.
Usage:
python scripts/aggregate_events.py \
--input events/ \
--status active,completed \
--output summary.json
Arguments:
--input: Input directory with event JSON files--status: Filter by status (comma-separated)--output: Output JSON fileMerge data from multiple sources.
Usage:
python scripts/merge_sources.py \
--sources app_store.json github.json skillz.json \
--strategy combine \
--output combined.json
Arguments:
--sources: Space-separated list of JSON files--strategy: Merge strategy (combine, average, latest)--output: Output JSON fileMerge strategies:
combine: Combine all data (keep all fields)average: Average numeric fieldslatest: Keep latest values (by timestamp)from aggregate_sales import filter_data
sales = [...]
# Filter by country
us_sales = filter_data(sales, country='US')
# Filter by date range
recent_sales = filter_data(sales, start_date='2026-01-01', end_date='2026-01-14')
# Filter by value
high_revenue = filter_data(sales, min_revenue=100)
from aggregate_commits import group_data
commits = [...]
# Group by author
by_author = group_data(commits, group_by='author')
# Group by repository
by_repo = group_data(commits, group_by='repository')
# Group by date
by_date = group_data(commits, group_by='date', period='day')
from merge_sources import sort_data
data = [...]
# Sort by revenue (descending)
sorted_data = sort_data(data, field='revenue', reverse=True)
# Sort by date (ascending)
sorted_data = sort_data(data, field='date')
# Aggregate App Store sales
from aggregate_sales import aggregate_sales
sales_data = appstore_client.get_sales_report(days=7)
aggregated = aggregate_sales(sales_data, period='day', group_by='app')
# Use for report
html = render_template('appstore-metrics', aggregated)
# Aggregate GitHub commits
from aggregate_commits import aggregate_commits
commits = github_client.get_commits(repo='owner/repo', days=7)
summary = aggregate_commits(commits, period='week')
# Create ClickUp task if high activity
if summary['total_commits'] > 50:
clickup_client.create_task(
title='High GitHub Activity',
description=f"Total commits: {summary['total_commits']}"
)
See examples/ directory for:
sample_sales_aggregation.json - App Store sales examplesample_commit_aggregation.json - GitHub commits examplesample_multi_source_merge.json - Multi-source merge exampleWeekly Installs
1
Repository
First Seen
1 day ago
Security Audits
Installed on
zencoder1
amp1
cline1
openclaw1
opencode1
cursor1
Python PDF处理教程:合并拆分、提取文本表格、创建PDF文件
59,800 周安装