Search code examples
weka

ARFF to CSV multiple files conversions


Anyone successfully tried to convert many ARFF files to CSV files from windows Command line.

I tried to use weka.core.converters.CSVSaver but it works for a single file only.

Can it be done for multiple files?


Solution

  • I found a way to solve this conversion by using R as shown in the following Script:

    #### Set the default directory to the folder that contains all ARFF files 
    
    temp = list.files(pattern="*.arff")
    library(foreign)
    
    for (i in 1:length(temp)) assign(temp[i], read.arff(temp[i]))
    
    for(i in 1:length(temp))
    {
    mydata=read.arff(temp[i])
    t=temp[i]
    x=paste(t,".csv")
    write.csv(mydata,x,row.names=FALSE)
    mydata=0
    }