BestPromptFinder
Python: Download a CSV From a URL
94AI Quality /100
85AI Usefulness est. /100
70Eval Confidence /100
No votes yetCommunity results
The prompt
Write a production-ready Python function that downloads a CSV file from a URL and saves it locally. Requirements - Signature: `download_csv(url: str, dest_path: str, timeout: int = 30) -> str` returning the saved path. - Use `requests` with streaming (`iter_content`, 1 MB chunks) so large files don't load into memory. - Raise a clear exception with the status code on non-2xx responses; handle timeouts and connection errors. - Write to a temporary file first, then rename, so a failed download never leaves a half file. - Create parent folders if missing. Output 1. The function with docstring and type hints. 2. A short usage example. 3. How to load the result into pandas (`pd.read_csv`), including an encoding fallback. 4. Two pytest tests using a mocked response.Find similar in the app →
Did this prompt work for you?
Why this prompt
- AI-graded 94/100 for quality and structure
- Written for GPT-5.6
Source
Created by BestPromptFinder — editorial prompt, not user-generated. See our content & source policy.
Related Coding prompts
Public-Market and Competitor Data Collection AgentQuality 92 · GPT-5.6AI2sql SQL Model - Query Generator
Quality 90 · GPT-5.6PRD to MVP Technical Plan
Quality 90 · Claude CodeThird-Party API Integration
Quality 90 · Claude CodeDatabase Schema and Migration
Quality 90 · Claude CodeCost-Aware AI Workflow Router
Quality 90 · Claude, Gemini