How can I create an .arff file from .txt?

user1424341 picture user1424341 · May 29, 2012 · Viewed 45.5k times · Source

Is there any simple way to do that? I'm not in Java and I'm new in Python so I would need another way(s). Thanks in advance!

Answer

kaz picture kaz · May 30, 2012

Do you perhaps mean a csv file that ends in .txt? If the data inside the file looks like this:

1,434,2236,5,569,some,value,other,value
4,347,2351,1,232,different,value,than,those

Then it has comma separated values (csv) and Weka has classes and functions which convert a csv file into an arff: http://weka.wikispaces.com/Converting+CSV+to+ARFF You can use these from the command line, like this:

java weka.core.converters.CSVLoader filename.csv > filename.arff

Otherwise, @D3mon-1stVFW 's comment links to great documentation from weka about turning text files (things like blog posts or books or essays) into the arff format. http://weka.wikispaces.com/ARFF+files+from+Text+Collections and this can also be called from the command line, like this:

java weka.core.converters.TextDirectoryLoader /directory/with/your/text/files > output.arff