lib/weka-lib.js
function parseArffFile(arffObj, cb) {

    var arffFile = '';
    arffFile += '@relation ';
    arffFile += arffObj.name;
    arffFile += '\n\n';

    async.waterfall([
      function (callback) {

        var i = 0;

        async.eachSeries(arffObj.data, function (obj, dataCb) {

          async.eachSeries(_.keys(obj), function (key, mapCb) {

            if (arffObj.types[key].type.indexOf('nominal') > -1 && !_.isString(arffObj.data[i][key])) {
              arffObj.data[i][key] = arffObj.types[key].oneof[arffObj.data[i][key]];
            }

            mapCb();

          }, function (err) {
            i++;
            dataCb(err);
          });

        }, function (err) {
          callback(err);
        });

      },
      function (callback) {

        async.eachSeries(arffObj.attributes, function (obj, attrCb) {

          arffFile += '@attribute ';
          arffFile += obj;
          arffFile += ' ';

          if (arffObj.types[obj].type.indexOf('nominal') > -1) {
            arffFile += '{' + arffObj.types[obj].oneof + '}';
          } else {
            arffFile += arffObj.types[obj].type;
          }

          arffFile += '\n';

          attrCb();

        }, function (err) {
          callback(err);
        });

      },
      function (callback) {

        arffFile += '\n';
        arffFile += '@data';
        arffFile += '\n';

        async.eachSeries(arffObj.data, function (obj, dataCb) {

          arffFile += _.values(obj);
          arffFile += '\n';

          dataCb();

        }, function (err) {
          callback(err);
        });
      }
    ], function (err, result) {

      var fileId = '/tmp/node-weka-' + _.random(0, 10000000) + '.arff';

//    console.log(arffFile);

      fs.writeFile(fileId, arffFile, function (err) {
        cb(err, fileId);
      });

    });

  }
function parseArffFile(arffObj, cb) {

    var arffFile = '';
    arffFile += '@relation ';
    arffFile += arffObj.name;
    arffFile += '\n\n';

    async.waterfall([
      function (callback) {

        var i = 0;

        async.eachSeries(arffObj.data, function (obj, dataCb) {

          async.eachSeries(_.keys(obj), function (key, mapCb) {

            if (arffObj.types[key].type.indexOf('nominal') > -1 && !_.isString(arffObj.data[i][key])) {
              arffObj.data[i][key] = arffObj.types[key].oneof[arffObj.data[i][key]];
            }

            mapCb();

          }, function (err) {
            i++;
            dataCb(err);
          });

        }, function (err) {
          callback(err);
        });

      },
      function (callback) {

        async.eachSeries(arffObj.attributes, function (obj, attrCb) {

          arffFile += '@attribute ';
          arffFile += obj;
          arffFile += ' ';

          if (arffObj.types[obj].type.indexOf('nominal') > -1) {
            arffFile += '{' + arffObj.types[obj].oneof + '}';
          } else {
            arffFile += arffObj.types[obj].type;
          }

          arffFile += '\n';

          attrCb();

        }, function (err) {
          callback(err);
        });

      },
      function (callback) {

        arffFile += '\n';
        arffFile += '@data';
        arffFile += '\n';

        async.eachSeries(arffObj.data, function (obj, dataCb) {

          arffFile += _.values(obj);
          arffFile += '\n';

          dataCb();

        }, function (err) {
          callback(err);
        });
      }
    ], function (err, result) {

      var fileId = '/tmp/node-weka-' + _.random(0, 10000000) + '.arff';

//    console.log(arffFile);

      fs.writeFile(fileId, arffFile, function (err) {
        cb(err, fileId);
      });

    });

  }
function parseArffFile ( arffObj , cb ) { var arffFile = '' ; arffFile += '@relation ' ; arffFile += arffObj . name ; arffFile += '\n\n' ; async . waterfall ( [ function ( callback ) { var i = 0 ; async . eachSeries ( arffObj . data , function ( obj , dataCb ) { async . eachSeries ( _ . keys ( obj ) , function ( key , mapCb ) { if ( arffObj . types [ key ] . type . indexOf ( 'nominal' ) > - 1 && ! _ . isString ( arffObj . data [ i ] [ key ] ) ) { arffObj . data [ i ] [ key ] = arffObj . types [ key ] . oneof [ arffObj . data [ i ] [ key ] ] ; } mapCb ( ) ; } , function ( err ) { i ++ ; dataCb ( err ) ; } ) ; } , function ( err ) { callback ( err ) ; } ) ; } , function ( callback ) { async . eachSeries ( arffObj . attributes , function ( obj , attrCb ) { arffFile += '@attribute ' ; arffFile += obj ; arffFile += ' ' ; if ( arffObj . types [ obj ] . type . indexOf ( 'nominal' ) > - 1 ) { arffFile += '{' + arffObj . types [ obj ] . oneof + '}' ; } else { arffFile += arffObj . types [ obj ] . type ; } arffFile += '\n' ; attrCb ( ) ; } , function ( err ) { callback ( err ) ; } ) ; } , function ( callback ) { arffFile += '\n' ; arffFile += '@data' ; arffFile += '\n' ; async . eachSeries ( arffObj . data , function ( obj , dataCb ) { arffFile += _ . values ( obj ) ; arffFile += '\n' ; dataCb ( ) ; } , function ( err ) { callback ( err ) ; } ) ; } ] , function ( err , result ) { var fileId = '/tmp/node-weka-' + _ . random ( 0 , 10000000 ) + '.arff' ; //    console.log(arffFile); fs . writeFile ( fileId , arffFile , function ( err ) { cb ( err , fileId ) ; } ) ; } ) ; }
JS Arff format back to weka arff format
JS Arff format back to weka arff format