Spaces:
Sleeping
Sleeping
import pandas as pd | |
def preprocess_csv(data): | |
""" | |
Preprocesses CSV data and returns a single string. | |
Args: | |
data: Either a DataFrame containing CSV data or a file path to a CSV file. | |
Returns: | |
A string containing the preprocessed text. | |
""" | |
if isinstance(data, pd.DataFrame): | |
# Process DataFrame directly | |
df = data | |
else: | |
# Read CSV from file path | |
df = pd.read_csv(data) | |
# Preprocess the data (replace with your specific logic) | |
# Example: Combine relevant columns into a single string | |
text = " ".join(str(word) for col in df.columns for word in df[col].tolist()) | |
return text | |