Code Monkey home page Code Monkey logo

csvlint.js's Introduction

CSVLint

Linting CSV file and report warnings or errors, implementing specification rfc4180.

http://tools.ietf.org/html/rfc4180

Origin

CSV files are using in various of fields like scientests, programmers, and ... . Because of the popularity of CSV, having a right convention is really important. So this is CSVLint come up with.

Install

npm install csvlint

Usage

var rs = fs.createReadStream('./test/test6.csv');
var ws = fs.createWriteStream('./test/output.csv');
var csvlint = csvlint();
rs.pipe(csvlint).pipe(ws);

csvlint.on('readable', function() {
})

csvlint.on('data', function(data) {
    console.log(data)
})

Using CSVlint you could pipe into another stream after lint is done. As the sample above after linting pipe into a write stream to file ./test/output.csv

Options (csvlint(options))

Options are optional.

  • encoding: default to utf8
  • delimiter: default to ,
  • newlint: default to \n
  • quote: default to \"

Definitions

For definitions we implement the definition in rfc4180

  1. Each record is located on a separate line, delimited by a line break (CRLF).

  2. The last record in the file may or may not have an ending line break.

  3. There maybe an optional header line appearing as the first line of the file with the same format as normal record lines. This header will contain names corresponding to the fields in the file and should contain the same number of fields as the records in the rest of the file (the presence or absence of the header line should be indicated via the optional "header" parameter of this MIME type).

  4. Within the header and each record, there may be one or more fields, separated by commas. Each line should contain the same number of fields throughout the file. Spaces are considered part of a field and should not be ignored. The last field in the record must not be followed by a comma.

  5. Each field may or may not be enclosed in double quotes (however some programs, such as Microsoft Excel, do not use double quotes at all). If fields are not enclosed with double quotes, then double quotes may not appear inside the fields.

  6. If double-quotes are used to enclose fields, then a double-quote appearing inside a field must be escaped by preceding it with another double quote.

Inspired by

http://csvlint.io/

License

MIT

csvlint.js's People

Watchers

James Cloos avatar

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.