Converting an ARFF file to a CSV file

First, let's look at the code. Suppose that we have a weather.arff file. We will first import the following packages:

import weka.core.Instances;import weka.core.converters.ArffLoader;import weka.core.converters.CSVSaver;import java.io.File;

We have started with the ArffLoader class, and have created an object, loader, for it:

ArffLoader loader = new ArffLoader();

We have then assigned a filename, weather.arff, to the ArffLoader class, as seen in the following code:

loader.setSource(new File("weather.arff")); //Use the path where your file is saved.

We have also called the loader.setSource method and assigned a filename to it by using our File object. Once this is done, we will load this particular dataset ...

Get Hands-On Artificial Intelligence with Java for Beginners now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.