chat1
import csv
import itertools
import pandas as pd
def generate_combinations(input_file, output_file):
# Load the CSV file into a pandas DataFrame
df = pd.read_csv(input_file)
# Generate all possible row combinations by creating a list of lists with each column's unique values
columns_data = [df[col].unique() for col in df.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')