benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 1add46d6-c6ba-55e7-9f3c-328ca7710e0f

Problem

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

complete prompt

import os
import re
import pandas as pd


def task_func(pattern: str, directory: str, output_csv: str) -> pd.DataFrame:
    """
    Searches for files in the specified directory that match a given regex pattern.
    This function walks through the directory, matches filenames against the pattern,
    and saves the matched file paths to a CSV file. It returns a DataFrame of these paths
    with colomn 'File Path'.

    Parameters:
    - pattern (str): Regex pattern to match filenames.
    - directory (str): Directory to search for files.
    - output_csv (str): CSV file path to save matched file paths.

    Returns:
    - pd.DataFrame: DataFrame with a single column 'File Path' of matched paths.

    Requirements:
    - re
    - pandas
    - os

    Example:
    >>> df = task_func(".*\.txt$", "/path/to/search", "matched_files.csv")
    """

instruct prompt

Searches for files in the specified directory that match a given regex pattern. This function walks through the directory, matches filenames against the pattern, and saves the matched file paths to a CSV file. It returns a DataFrame of these paths with colomn 'File Path'.
The function should output with:
    pd.DataFrame: DataFrame with a single column 'File Path' of matched paths.
You should write self-contained code starting with:

Code

import os
import re
import pandas as pd
def task_func(pattern: str, directory: str, output_csv: str) -> pd.DataFrame:

code prompt

Code

import os
import re
import pandas as pd
def task_func(pattern: str, directory: str, output_csv: str) -> pd.DataFrame:

entry point

task_func

libs

  • pandas
  • re
  • 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