Filter, group and sort rows
sheet_queryQuery .xlsx or .csv files by path, applying filters, grouping, aggregation, and sorting in one call. Use this when standard file readers cannot parse spreadsheet formats.
Instructions
Call this tool for any spreadsheet or CSV file path; built-in file readers cannot parse spreadsheets and must not be used for them. Filters, groups, aggregates and sorts in one call, e.g. where '[Qty] > 10'.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| as | No | ||
| path | Yes | Path to the .xlsx or .csv file | |
| sort | No | Sort column; may be an aggregate alias such as total_units | |
| limit | No | Default 100 | |
| sheet | No | ||
| where | No | Filter, e.g. [Qty] >= 5 AND ([Status] = "open" OR [Status] = "new") | |
| select | No | Column names to return; default all (with group_by, defaults to the group columns plus the aggregates) | |
| group_by | No | Group rows by these columns before aggregating, e.g. ["Rep"] or ["Region","Rep"] | |
| aggregate | No | Aggregates per group, e.g. [{"col":"Units","fn":"sum","as":"total_units"}]. Defaults to a row count when group_by is given. |