Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved the README, tweaked LICENSE #28

Merged
merged 1 commit into from
Jan 14, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions LICENSE.txt → LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Copyright (c) 2014 pezholio
##Copyright (c) 2014 The Open Data Institute

MIT License
#MIT License

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand All @@ -19,4 +19,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
61 changes: 56 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,77 @@
[![Coverage Status](https://coveralls.io/repos/theodi/csvlint.rb/badge.png)](https://coveralls.io/r/theodi/csvlint.rb) [![Build Status](https://travis-ci.org/theodi/csvlint.rb.png)](https://travis-ci.org/theodi/csvlint.rb)

# Csvlint.rb
# CSV Lint

TODO: Write a gem description
A ruby gem to support validating CSV files to check their syntax and contents.

## Installation

Add this line to your application's Gemfile:

gem 'csvlint.rb'
gem 'csvlint'

And then execute:

$ bundle

Or install it yourself as:

$ gem install csvlint.rb
$ gem install csvlint

## Usage

TODO: Write usage instructions here
Currently the gem supports retrieving a CSV accessible from a URL

require 'csvlint'

validator = Csvlint::Validator.new( "http://example.org/data.csv" )

#invoke the validation
validator.validate

#check validation status
validator.valid?

#access array of errors, each is an Csvlint::ErrorMessage object
validator.errors

#access array of warnings
validator.warnings

#get some information about the CSV file that was validated
validator.encoding
validator.content_type
validator.extension

#retrieve HTTP headers from request
validator.headers

## Error Reporting

Errors and warnings returned by the validator are instances of `Csvlint::ErrorMessage`:

* `content` holds the contents of the row that generated the error or warning
* `row` holds the line number of the problem
* `type` has a symbol that indicates the type of error or warning being reported

The following types of error can be reported:

* `:wrong_content_type` -- content type is not `text/csv`
* `:ragged_rows` -- row has a different number of columns (than the first row in the file)
* `:blank_rows` -- completely empty row, e.g. blank line or a line where all column values are empty
* `:invalid_encoding` -- encoding error when parsing row, e.g. because of invalid characters
* `:not_found` -- HTTP 404 error when retrieving the data
* `:quoting` -- problem with quoting, e.g. missing or stray quote, unclosed quoted field
* `:whitespace` -- a quoted column has leading or trailing whitespace

The following types of warning can be reported:

* `:no_encoding` -- the `Content-Type` header returned in the HTTP request does not have a `charset` parameter
* `:encoding` -- the character set is not UTF-8
* `:no_content_type` -- file is being served without a `Content-Type` header
* `:excel` -- no `Content-Type` header and the file extension is `.xls`
* `:check_options` -- CSV file appears to contain only a single column
* `:inconsistent_values` -- inconsistent values in the same column. Reported if <90% of values seem to have same data type (either numeric or alphanumeric including punctuation)

## Contributing

Expand Down