benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf e9854001-a5e4-52d0-9246-d4959cf0df9c

Problem

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

complete prompt

import os
import csv
from openpyxl import load_workbook

def task_func(file_name, excel_file_path, csv_file_path) -> str:
    """
    Converts an Excel file (.xls or .xlsx) to a CSV file by reading the contents of the Excel file
    and writing them to a new CSV file with the same name but a different extension. Allows specifying
    separate paths for the Excel file source and the CSV file destination.

    Parameters:
        file_name (str): The name of the Excel file to be converted.
        excel_file_path (str): The directory path where the Excel file is located.
        csv_file_path (str): The directory path where the CSV file should be saved.

    Returns:
        str: The name of the created CSV file.

    Requirements:
    - openpyxl.load_workbook
    - os
    - csv

    Example:
    >>> task_func('test.xlsx', '/path/to/excel/files', '/path/to/csv/files')
    'test.csv'
    >>> task_func('nonexistent.xlsx', '/path/to/excel/files', '/path/to/csv/files')
    Traceback (most recent call last):
       ...
    FileNotFoundError: [Errno 2] No such file or directory: '/path/to/excel/files/nonexistent.xlsx'

    Note:
    - This function assumes the active sheet is the one to be converted.
    """

instruct prompt

Converts an Excel file (.xls or .xlsx) to a CSV file by reading the contents of the Excel file and writing them to a new CSV file with the same name but a different extension. Allows specifying separate paths for the Excel file source and the CSV file destination.
Note that: This function assumes the active sheet is the one to be converted.
The function should output with:
    str: The name of the created CSV file.
You should write self-contained code starting with:

Code

import os
import csv
from openpyxl import load_workbook
def task_func(file_name, excel_file_path, csv_file_path) -> str:

code prompt

Code

import os
import csv
from openpyxl import load_workbook
def task_func(file_name, excel_file_path, csv_file_path) -> str:

entry point

task_func

libs

  • csv
  • openpyxl
  • os

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