benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 2de41aa8-f9ce-5cac-9536-abbb4a2e0648

Problem

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

complete prompt

import subprocess
import csv
import glob
import random
import os

def task_func(file):
    """
    Divide a CSV file into several smaller files and shuffle the lines in each file.
    
    This function takes a CSV file path as input, divides it into smaller files using 
    the shell 'split' command, and shuffles the rows in each of the resulting files.
    The output files are named with a 'split_' prefix.

    Parameters:
    - file (str): The path to the CSV file.

    Returns:
    - list: The paths to the split files. Returns an empty list if the file does not exist, is not a CSV file, or if an error occurs during processing.
    
    Requirements:
    - subprocess
    - csv
    - glob
    - random
    - os

    Example:
    >>> task_func('/path/to/file.csv')
    ['/path/to/split_00', '/path/to/split_01', ...]
    """

instruct prompt

Divide a CSV file into several smaller files and shuffle the lines in each file. This function takes a CSV file path as input, divides it into smaller files using the shell 'split' command, and shuffles the rows in each of the resulting files. The output files are named with a 'split_' prefix.
The function should output with:
    list: The paths to the split files. Returns an empty list if the file does not exist, is not a CSV file, or if an error occurs during processing.
You should write self-contained code starting with:

Code

import subprocess
import csv
import glob
import random
import os
def task_func(file):

code prompt

Code

import subprocess
import csv
import glob
import random
import os
def task_func(file):

entry point

task_func

libs

  • glob
  • subprocess
  • random
  • os
  • csv

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