fetch_data_to_file
Stream large query results to a CSV file instead of the reply, bypassing context limits and returning a path for analysis in R, DuckDB, or pandas.
Instructions
Stream an unrestricted query to a CSV file instead of into the reply.
For results too large to read: whole geography types, long time series, LSOA-level census tables. Nothing is loaded into memory or context, so use this rather than paging fetch_data hundreds of times.
Without an API key the file is still capped at 25,000 records; run check_auth first if the row count looks suspiciously round.
Returns the path for onward analysis in R, DuckDB or pandas.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| select | No | Columns to include. Default: all. | |
| filters | Yes | Same as fetch_data. Codes from search_codes. | |
| filename | Yes | Output filename, e.g. 'lsoa_claimants.csv'. Written to the server's download directory. | |
| dataset_id | Yes | Dataset id, e.g. NM_1_1 |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||