Parameters
The unique identifier of the resource to download.This ID can be obtained from the
list_dataset_resources or get_resource_info tool results.Maximum number of rows to return.Start with the default (20) to preview structure and file size. If you need all data, call again with a higher value. This limits the rows displayed, not downloaded.
Maximum file size to download in megabytes.Downloads will be rejected if the file exceeds this size. Maximum: 500 MB. This is a safety limit to prevent memory issues.
Returns
Returns a formatted text response containing:- Resource title and ID
- Download URL
- Downloaded file size
- Detected file format
- Total rows in file
- Number of rows returned (limited by
max_rows) - Column names
- All parsed data rows (up to
max_rows, values truncated to 100 characters if longer) - Warning if file contains more rows than
max_rows
Supported formats
The tool supports the following file formats:- CSV - Comma-separated values (automatic delimiter detection for
,,;,\t,|) - CSV.GZ - Gzipped CSV files (automatically decompressed)
- JSON - JSON arrays or single objects
- JSONL - JSON Lines (one JSON object per line)
XLSX and XLS formats are not currently supported by this tool. For Excel files, use
query_resource_data if the file is available via the Tabular API.Usage notes
When to use this tool
Usedownload_and_parse_resource when:
- Working with JSON or JSONL files (not supported by Tabular API)
- The resource is not available via Tabular API (check with
get_resource_info) - The file exceeds Tabular API limits (CSV > 100 MB, XLSX > 12.5 MB)
- You need full dataset analysis for large datasets (>1000 rows) instead of paginating
- The resource has an external URL not hosted on data.gouv.fr
When NOT to use this tool
For CSV/XLSX files available via Tabular API, preferquery_resource_data for:
- Faster preview without downloading the entire file
- Filtering and sorting capabilities
- Efficient querying of specific data
Download strategy
- First call: Use
max_rows=20to preview structure - Check total rows: See how many rows are in the file
- Second call: If needed, increase
max_rowsto get all data
CSV delimiter detection
For CSV files, the tool automatically detects the delimiter:- Tries to sniff the delimiter from the first 5 lines
- Falls back to counting occurrences of common delimiters (
,,;,\t,|) - Uses the delimiter with the most occurrences (minimum 2 to avoid false positives)
Compression support
Gzipped files (.gz extension or gzip Content-Type) are automatically decompressed before parsing.
Error handling
The tool handles the following error cases:- Resource not found: Returns error if resource ID is invalid
- No download URL: Returns error if resource has no URL
- File too large: Returns error if file exceeds
max_size_mb - Unsupported format: Returns error with list of supported formats
- Download failures: Returns HTTP error details
- Parse errors: Returns parsing error message
- Empty files: Returns warning if no data rows found
Example workflows
Preview JSON file
Full analysis of large CSV
Compare with Tabular API
For files available via both methods:- Use
query_resource_datafor: Quick previews, filtered queries, exploring data - Use
download_and_parse_resourcefor: Full data dumps, comprehensive analysis, data processing