chat1
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)
# Drop any rows where all columns are empty
df.dropna(how='all', inplace=True)
# Gather unique non-empty entries in each column
columns_data = [df[col].dropna().unique() for col in df.columns]
# Generate all possible combinations 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')