This tutorial explains how to convert CSV to ARFF. Here I will list some tools that you can use to easily convert a CSV file to ARFF. In the following list, I have added some online as well as some offline command line tools. Using all the tools, you can get an ARFF file out of a CSV file. These tools take a CSV file from you along with some attributes like column data types, column names, etc. Also, some of these tools are advanced as they automatically identify the data type of the columns in CSV. And then after processing the CSV file, they generate the equivalent ARFF file that you can use anywhere you want.
ARFF or Attribute-Relation File Format is a special data file formats that is used in programs that use some machine learning approach. Those tools don’t take data directly from the files like CSV, Excel, Text, etc. You will have to first convert the data to ARFF format and then supply that to the AI tools or software for research or any other purpose. And that is where these free software and online tool come in handy. In the post below, I will talk about 3 such tools which let you do that.
How to Convert CSV to ARFF?
Convert CSV to ARFF Online with CSV2ARFF
CSV2ARFF is a simple and the only one of its kind of tool that lets you convert CSV to ARFF. Here it takes a CSV file from you and then simply returns the corresponding ARFF file. When you upload a CSV file from your PC, it processes that and automatically identifies what is the data type of the different columns. And if there is a mistake in identifying the data type of a column, then you can correct that. It lets you define the data type explicitly as well. And in the end, it gives you the ARFF file that you can download on your PC. Simple as that.
Just reach the homepage of this online tool and then upload an input CSV file. After that, it will show you the name of the columns with their predicted data type. If the column names are correctly matched with the correct data type, then you can proceed with the conversion. And if not then you can specify the correct data types. After that, you can hit the “Generate my ARFF” and it will automatically give you the final ARFF file which will start downloading automatically.
Convert CSV to ARFF with a Free Command Line tool: Csv2arff
Csv2arff is a free and open source command line tool to convert a CSV file to ARFF. This tool requires Python to be installed on your PC to work. It takes a CSV file from you and then saves the corresponding ARFF file in the current working directory. There are a couple of commands in it that you can use to install it and then use it for CSV to ARFF conversion. Apart from taking the input CSV file, you can even opt to specify other parameters. You can specify the ARFF relation name, CSV delimiter, and opt for verbose output.
These are a few steps to use this command line tool to convert a CSV file to ARFF.
Step 1: Make sure that you have Python installed and then open a command prompt. In the command prompt, run the following command to install Csv2arff on your PC.
Step 2: Now, run this command to convert a CSV file to ARFF. And before executing the command, I will suggest you to keep the CSV file in the same working directory for easy access.
After running the above command, it will save the corresponding ARFF file in the same directory. And from now on, you can use this tool in the same way. Also, it gets installed globally on your PC so you can access it from any folder on your PC.
A Free Script to Convert CSV to ARFF: CSV-to-ARFF
CSV-to-ARFF is a free Python script that helps you convert a CSV file to ARFF. And it is quite intelligent as well as it asks you to specify the data type of different columns explicitly. Just like the above tools, it takes a CSV file from you and then save the corresponding ARFF file in the current working directory. You can execute it from the command prompt and convert any CSV file to ARFF in blink of an eye. It beautifully adds all the attributes and relation names in the final ARFF file and save it.
Here are a few steps to use this script for CSV to ARFF conversion.
Step 1: Copy or download this Python script from URL above and then save it on your PC. And along with this script, you can put the target CSV file in the same directory as well. You can give a simple name to the Python script, say “CSVarff.py”.
Step 2: Open command prompt in the same folder where you have downloaded the script. After that, simply run this command. It will then ask you the name of the CSV file to be converted to ARFF. Also, afterwards it will ask you to type the data type of the columns of the CSV.
After running the above command, it will save the corresponding ARRF file in the same working directory. Also, since this is a script, then you can run it by simply double clicking as well.
Wrapping things up…
If you are in a field where you work with the data to be used in AI tools like Weka, then you can use the above mentioned tools to do that. You just have to give these tools a CSV file with some parameters and they will return the corresponding ARFF file to you quickly. So, if you are looking for some free CSV to ARFF converters, then this post may come in handy.