benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 0b950bde-6e25-59f3-aba5-8f4999f4482c

Problem

Answer published by the source. Consult the official source to check your work against its answer.

complete prompt

import json
import csv
import requests
from io import StringIO

# Constants
CSV_URL = 'https://example.com/data.csv'
JSON_FILE = 'data.json'

def task_func(csv_url=CSV_URL, json_file_path=JSON_FILE):
    """
    Downloads a CSV file from a specified URL, converts it to JSON format, and saves it to a specified file path.
    
    Parameters:
    - csv_url (str): The URL from which the CSV data should be downloaded. Defaults to a constant CSV_URL.
    - json_file_path (str): The file path where the JSON data should be saved. Defaults to a constant JSON_FILE.

    Returns:
    str: The path to the saved JSON file.

    Requirements:
    - json
    - csv
    - requests
    - io.StringIO

    Example:
    >>> task_func("https://example.com/sample.csv", "sample.json")
    "sample.json"
    """

instruct prompt

Downloads a CSV file from a specified URL, converts it to JSON format, and saves it to a specified file path.
The function should output with:
    str: The path to the saved JSON file.
You should write self-contained code starting with:

Code

import json
import csv
import requests
from io import StringIO
# Constants
CSV_URL = 'https://example.com/data.csv'
JSON_FILE = 'data.json'
def task_func(csv_url=CSV_URL, json_file_path=JSON_FILE):

code prompt

Code

import json
import csv
import requests
from io import StringIO
# Constants
CSV_URL = 'https://example.com/data.csv'
JSON_FILE = 'data.json'
def task_func(csv_url=CSV_URL, json_file_path=JSON_FILE):

entry point

task_func

libs

  • io
  • csv
  • requests
  • json

Discussion

Discussion

No discussion posts on this page yet. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

See answer Answer published by the source

Artifacts

Code, notes and reproducible work shared by participants. Files are served from a separate origin.

No artifacts on this page yet. Share reproducible code or notes in a contribution. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

Source and history

Official source

initial import