chat1
import csvimport itertools
import pandas as pd
import itertools
def generate_combinations(input_file, output_file):
# Load the CSV file into a pandas DataFrame
df = pd.read_csv(input_file)
# ReplaceDrop NaNany withrows anwhere all columns are empty string to treat empty cells as valid entries
dfdf.dropna(how='all', = df.fillna('')inplace=True)
# Generate a list ofGather unique values (including non-empty strings)entries forin each column
columns_data = [df[col].dropna().unique() for col in df.columns]
# Use itertools.product to getGenerate all possible combinations of values across columns
combinations = list(itertools.product(*columns_data))
# Create a new DataFrame from the combinations and write to CSV
output_df = pd.DataFrame(combinations, columns=df.columns)
output_df.to_csv(output_file, index=False)
print(f"Combinations have been saved to {output_file}")
# Usage example:
generate_combinations('input.csv', 'output.csv')