GithubHelp home page GithubHelp logo

js-arff's Introduction

arff Build Status

ARFF parsing and formatting

Install

Download manually or with package-manager.

> npm install --save arff

Usage

var arff = require('arff');

Parsing

var readFile = require('fs').readFile;

readFile('data.arff', 'utf8', function (error, content) {
  if (error) {
    return console.error(error);
  }

  console.log(arff.parse(content));
});

For the folling data.arff:

% My ARFF file.
@RELATION user

@ATTRIBUTE name       STRING
@ATTRIBUTE lastSignIn DATE
@ATTRIBUTE group      {none,read,write,admin}

@DATA
root,?,admin
julien-f,2014-12-16T19:42:01,write

It will give this output:

{
  relation: 'user',
  attributes: [
    {
      name: 'name',
      type: 'string'
    },
    {
      name: 'lastSignIn',
      type: 'date'
    },
    {
      name: 'name',
      type: 'enum',
      values: [
        'none',
        'read',
        'write',
        'admin'
      ]
    }
  ],
  data: [
    {
      name: 'root',
      group: 'admin'
    },
    {
      name: 'julien-f',
      lastSignIn: '2014-12-16T19:42:01',
      group: 'write'
    }
  ]
}

Formatting

console.log(arff.format(require('./relation')));

Which will display:

@RELATION foo

@ATTRIBUTE date date
@ATTRIBUTE dateWithFormat date "MM/DD/YY"
@ATTRIBUTE numeric numeric
@ATTRIBUTE string string
@ATTRIBUTE enumerate {"foo","bar","baz"}

@DATA
"2014-12-16T19:42:01+00:00","06/23/15",3.259,"can have spaces","bar"
"2014-12-16T19:42:01+00:00",?,42,?,?

Contributing

Contributions are very welcome, either on the documentation or on the code.

You may:

  • report any issue you've encountered;
  • fork and create a pull request.

License

ISC © Julien Fontanet

js-arff's People

Contributors

julien-f avatar greenkeeperio-bot avatar

Stargazers

Danillo avatar Todd Morrison avatar Julien Marinescu avatar

Watchers

 avatar James Cloos avatar 季长冰(Aid) avatar

js-arff's Issues

Support tab as a field seperator

The specification does not mention the possibilities to use tab as a field separator but it seems that other softwares do.

It would make sense to support it as long as it does not cause issues.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.