How to Convert CSV file to weka arff format

Please find the python code to convert the file csv into arff format (GitHub).

Python file:

Step 1: Place the “” file in same directory where your input file is.

Step 2: Open the python file and update the filename. [Default is “Data.csv”]


Beef, Bread
Bread, Clothes
Bread, Clothes, Milk
Cheese, Boots
Beef, Bread, Cheese, Shoes
Beef, Bread, Cheese, Milk
Bread, Milk, Clothes


@relation Weka
@attribute Cheese {false,true}
@attribute Shoes {false,true}
@attribute Beef {false,true}
@attribute Boots {false,true}
@attribute Bread {false,true}
@attribute Milk {false,true}
@attribute Clothes {false,true}

{ 2 true,4 true}
{ 4 true,6 true}
{ 4 true,6 true,5 true}
{ 0 true,3 true}
{ 2 true,4 true,0 true,1 true}
{ 2 true,4 true,0 true,5 true}
{ 4 true,5 true,6 true}