chat1
importFunction pandasOnlyContainsItems(arr() asAs pdimportVariant, itertools
defAs generate_combinations(input_file,Variant, output_file):item2 As Variant) As Boolean
#Dim Loaditem theAs CSV file into a pandas DataFrameVariant
dfFor Each item In arr
If item <> item1 And item <> item2 Then
OnlyContainsItems = pd.read_csv(input_file)False
Exit Function
#End Drop any rows where all columns are emptyIf
df.dropna(how='all',Next inplace=True)item
# Gather unique non-empty entries in each column columns_dataOnlyContainsItems = [df[col].dropna().unique()True
End 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}")Function
# Usage example:generate_combinations('input.csv', 'output.csv')