csv-query
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "csv-query" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-f5167d8e5a4ae688a5fd7858a5fa3f5052a1b5e8a634a09ab3e6e6cf3d96a1fd. Verify the upstream source and version against https://github.com/Kilo-Org/kilo-marketplace before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
github.com
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
Run SQL queries against CSV, TSV, or Excel files using the Polars SQL engine.
Introduction source: third_party · Kilo-Org · 0.0.1 Reference
SkillPi interpretation
- Tasks
- Run SQL queries against CSV/TSV/Excel files using Polars SQL engine
- Testing
- Not tested
Browse files
Frontmatter
name: csv-query
description: Run SQL queries against CSV/TSV/Excel files using Polars SQL engine
allowed-tools:
- mcp__qsv__qsv_sniff
- mcp__qsv__qsv_count
- mcp__qsv__qsv_headers
- mcp__qsv__qsv_index
- mcp__qsv__qsv_stats
- mcp__qsv__qsv_frequency
- mcp__qsv__qsv_search
- mcp__qsv__qsv_select
- mcp__qsv__qsv_sqlp
- mcp__qsv__qsv_command
- mcp__qsv__qsv_to_parquet
- mcp__qsv__qsv_list_files
- mcp__qsv__qsv_search_tools
- mcp__qsv__qsv_get_working_dir
- mcp__qsv__qsv_set_working_dir
metadata:
upstream:
user-invocable: true
argument-hint: '<file> [query]'
category: data
source:
repository: 'https://github.com/dathere/qsv'
path: .claude/skills/skills/csv-query
license_path: COPYING
commit: d7bcd2d9ac92ca2edcc6086a1132ea2beb6ab079CSV Query
Query tabular data files using SQL via the Polars-powered sqlp command.
Cowork note: If relative paths don't resolve, call
mcp__qsv__qsv_get_working_dirandmcp__qsv__qsv_set_working_dirto sync the working directory.
Decision Tree
Is the query simple (single column filter, basic select)?
- Yes -> Consider
select+searchfor simpler operations - No -> Use
sqlpfor full SQL support
Does the query involve joins, GROUP BY, window functions, or complex expressions?
- Yes -> Use
sqlp(Polars SQL engine)
Is the CSV file very large (> 10MB)?
- Yes -> Consider converting to Parquet with
mcp__qsv__qsv_to_parquetfor faster repeated queries. Note:sqlpcan also query CSV files of any size directly.
Steps
-
Prepare the file: Run
mcp__qsv__qsv_indexandmcp__qsv__qsv_statswithcardinality: true, stats_jsonl: trueto create index and stats cache. -
Read the stats cache: Read
<FILESTEM>.stats.csv(e.g.,data.stats.csvfordata.csv) to understand column metadata before writing SQL. This is the most important step for writing efficient queries. -
Run frequency on key columns: For columns you plan to GROUP BY, filter on, or join on, run
mcp__qsv__qsv_frequencyto see actual value distributions. This reveals the best filter values and whether a GROUP BY will produce a manageable result set. -
Write and run SQL: Use
mcp__qsv__qsv_sqlpwith the SQL query informed by stats and frequency data. The table name in SQL is the filename stem (e.g.,data.csv->SELECT * FROM data). For Parquet files, useread_parquet('data.parquet')as the table source instead. -
Refine if needed: Check results and adjust the query.
Using Stats to Write Better SQL
After reading the .stats.csv cache, use these columns to inform your SQL:
| Stats Column | How to Use in SQL |
|---|---|
type |
Use correct casts and comparisons — don't quote integers, use date functions for Date/DateTime columns |
min / max |
Write precise WHERE clauses using actual data range (e.g., WHERE price BETWEEN 10.5 AND 999.99 instead of arbitrary bounds) |
cardinality |
Estimate GROUP BY result size — low cardinality (< 100) is fast; high cardinality (> 10K) may need LIMIT or a different approach |
nullcount |
Only add COALESCE or IS NOT NULL where nullcount > 0 — skip null handling for columns with zero nulls |
sort_order |
Skip ORDER BY if data is already sorted on that column (sort_order = "Ascending"/"Descending") |
mean / stddev |
Write outlier filters: WHERE col BETWEEN mean - 3*stddev AND mean + 3*stddev |
median / q1 / q3 |
For skewed data (when mean and median diverge), use quartile-based ranges: WHERE col BETWEEN q1 AND q3 instead of mean ± stddev |
skewness |
If skewness > 1 or < -1, prefer median/quartile-based filters over mean-based ones |
cv |
High CV (> 100%) signals high relative variability — add LIMIT to GROUP BY queries and consider binning continuous values |
outliers_percentage |
If > 5%, consider excluding outliers before aggregation: WHERE col BETWEEN lower_inner_fence AND upper_inner_fence |
sparsity |
Columns with sparsity > 0.5 are mostly null — avoid using them as join keys or GROUP BY columns |
Using Frequency for Filter Values
Run mcp__qsv__qsv_frequency with select: "col", limit: 20 before writing WHERE clauses on categorical columns:
- Pick selective filters: If
frequencyshows "active" has 90% of rows, filtering onWHERE status = 'active'is wasteful — filter on the rare values instead - Validate expected values: If you plan
WHERE category IN ('A','B','C'), check frequency first to confirm those values exist and see if you're missing any - Avoid GROUP BY on high-cardinality columns: If frequency shows thousands of unique values, GROUP BY will produce a huge result — add LIMIT or aggregate differently
SQL Syntax Guide
The sqlp command uses Polars SQL dialect:
-- Basic select
SELECT col1, col2 FROM data WHERE col1 > 100
-- Aggregation
SELECT category, COUNT(*) as cnt, AVG(price) as avg_price
FROM data GROUP BY category ORDER BY cnt DESC
-- Window functions
SELECT *, ROW_NUMBER() OVER (PARTITION BY dept ORDER BY salary DESC) as rank
FROM employees
-- String operations
SELECT * FROM data WHERE col1 LIKE '%pattern%'
-- Date operations
SELECT *, EXTRACT(YEAR FROM date_col) as year FROM data
-- Multiple files (join)
SELECT a.*, b.name FROM file1 a JOIN file2 b ON a.id = b.id
-- CASE expressions
SELECT *, CASE WHEN amount > 1000 THEN 'high' ELSE 'low' END as tier FROM data
Table Naming Convention
- File:
sales_2024.csv-> Table:sales_2024 - File:
my-data.csv-> Table:"my-data"(quote if contains special chars) - Multiple files: each file is a separate table
Notes
sqlpuses the Polars engine - some PostgreSQL-specific syntax may not be supported- For very complex queries that fail, suggest DuckDB as an alternative
- The stats cache helps Polars choose optimal data types for columns
- Results go to stdout by default; use
--output file.csvfor large result sets - Column names are case-sensitive in SQL queries
- Use
LIMITto preview large result sets before running full queries sqlpcan query multiple CSV files in a single SQL statement (useful for joins)
Version history
-
skills-20261103210927-6c1b454
GitHub ↗
Original release notes
Automated skills release from commit 6c1b4543cac1d45a80bf5904e4b69ac315117323
-
skills-20260928190452-ff51758
GitHub ↗
Original release notes
Automated skills release from commit ff51758b06b8249007116184096765d47bdb7505
-
skills-20260924105536-d31110d
GitHub ↗
Original release notes
Automated skills release from commit d31110d62dc0bd00c22f1d6f6a630d1e702a0049
-
skills-20260923085113-cea285e
GitHub ↗
Original release notes
Automated skills release from commit cea285ef0e4d6ec47cd2fd9fdbca03813a3363c7
-
skills-20260922193956-97d7333
GitHub ↗
Original release notes
Automated skills release from commit 97d7333d8200e5ac556c659c8669f3a83ba10866
Only the five most recent versions are shown. View full version history at the source ↗
Current listing version
0.0.1
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 提供基于 Polars SQL 引擎对 CSV/TSV/Excel 文件运行 SQL 查询的能力,属于数据处理领域的高频刚需工具
- 功能完整,包含决策树、详细步骤、统计信息利用、SQL 语法指南等,显著提升用户在处理结构化数据时的效率
Highlights
- description 明确描述了核心功能,frontmatter 中 argument-hint 提供了参数提示 '<file> [query>',触发词覆盖合理,边界清晰
Highlights
- 文档结构清晰,包含决策树、步骤划分、使用统计信息编写更好 SQL 的详细说明、SQL 语法指南、表命名约定等
- 有端到端示例,frontmatter 完整,单文件未超过 500 行
Highlights
- 工具来源明确(qsv 系列工具),参数使用正确
- 覆盖了主要异常情况(如大文件处理建议、工作目录同步提示、复杂查询失败建议 DuckDB 替代等),不可逆操作有明确说明
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
These common operations were not identified in the main document. This does not mean no permissions or risks exist.
Domains or addresses referenced in the document
These addresses may be documentation links or examples, not an approved network allowlist. Verify actual destinations and outgoing data before use.
- github.com
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.