# fastercsv-1.5.5 Documentation

by James Edward Gray II

## Description

Welcome to FasterCSV.

FasterCSV is intended as a replacement to Ruby's standard CSV library. It was designed to address concerns users of that library had and it has three primary goals:

1. Be significantly faster than CSV while remaining a pure Ruby library.

2. Use a smaller and easier to maintain code base. (FasterCSV is larger now, but considerably richer in features. The parsing core remains quite small.)

3. Improve on the CSV interface.

Obviously, the last one is subjective. If you love CSV's interface, odds are good this one won't suit you. I did try to defer to that interface whenever I didn't have a compelling reason to change it though, so hopefully this won't be too radically different.

## What's Different From CSV?

I'm sure I'll miss something, but I'll try to mention most of the major differences I am aware of, to help others quickly get up to speed:

### CSV Parsing

- FasterCSV has a stricter parser and will throw MalformedCSVErrors on problematic data.

- FasterCSV has a less liberal idea of a line ending than CSV. What you set as the `:row_sep` is law.

- CSV returns empty lines as `[nil]`. FasterCSV calls them `[]`.

- FasterCSV has a much faster parser.

### Interface

- FasterCSV uses Hash-style parameters to set options.

- FasterCSV does not have generate_row() or parse_row() from CSV.

- FasterCSV does not have CSV's Reader and Writer classes.

- FasterCSV::open() is more like Ruby's open() than CSV::open().

- FasterCSV objects support most standard IO methods.

- FasterCSV has a new() method used to wrap objects like String and IO for reading and writing.

- FasterCSV::generate() is different from CSV::generate().

- FasterCSV does not support partial reads. It works line-by-line.

- FasterCSV does not allow the instance methods to override the separators for performance reasons. They must be set in the constructor.

If you use this library and find yourself missing any functionality I have trimmed, please let me know.

## Documentation

See FasterCSV for documentation.

## Installing

See the INSTALL file for instructions.

## What is CSV, really?

FasterCSV maintains a pretty strict definition of CSV taken directly from the RFC. I relax the rules in only one place and that is to make using this library easier. FasterCSV will parse all valid CSV.

What you don't want to do is feed FasterCSV invalid CSV. Because of the way the CSV format works, it's common for a parser to need to read until the end of the file to be sure a field is invalid. This eats a lot of time and memory.

Luckily, when working with invalid CSV, Ruby's built-in methods will almost always be superior in every way. For example, parsing non-quoted fields is as easy as:

    data.split(",")

## Questions and/or Comments

Feel free to email James Edward Gray II with any questions.

## Files

- AUTHORS
- CHANGELOG
- COPYING
- INSTALL
- LICENSE
- README
- TODO

## Classes/Modules

- FasterCSV
- FasterCSV
- FasterCSV::MalformedCSVError
- FasterCSV::Row
- FasterCSV::Table
- Object
- Object::FCSV
- Array
- String

## Methods

- ::build_csv_interface — FasterCSV
- ::build_csv_interface — FasterCSV
- ::build_csv_interface — FasterCSV
- ::const_missing — FasterCSV
- ::const_missing — FasterCSV
- ::const_missing — FasterCSV
- ::dump — FasterCSV
- ::dump — FasterCSV
- ::dump — FasterCSV
- ::filter — FasterCSV
- ::filter — FasterCSV
- ::filter — FasterCSV
- ::foreach — FasterCSV
- ::foreach — FasterCSV
- ::foreach — FasterCSV
- ::generate — FasterCSV
- ::generate — FasterCSV
- ::generate — FasterCSV
- ::generate_line — FasterCSV
- ::generate_line — FasterCSV
- ::generate_line — FasterCSV
- ::instance — FasterCSV
- ::instance — FasterCSV
- ::instance — FasterCSV
- ::load — FasterCSV
- ::load — FasterCSV
- ::load — FasterCSV
- ::method_missing — FasterCSV
- ::method_missing — FasterCSV
- ::method_missing — FasterCSV
- ::new — FasterCSV
- ::new — FasterCSV::Table
- ::new — FasterCSV::Row
- ::new — FasterCSV
- ::new — FasterCSV
- ::open — FasterCSV
- ::open — FasterCSV
- ::open — FasterCSV
- ::parse — FasterCSV
- ::parse — FasterCSV
- ::parse — FasterCSV
- ::parse_line — FasterCSV
- ::parse_line — FasterCSV
- ::parse_line — FasterCSV
- ::read — FasterCSV
- ::read — FasterCSV
- ::read — FasterCSV
- ::readlines — FasterCSV
- ::readlines — FasterCSV
- ::readlines — FasterCSV
- ::table — FasterCSV
- ::table — FasterCSV
- ::table — FasterCSV
- #<< — FasterCSV::Table
- #<< — FasterCSV
- #<< — FasterCSV::Row
- #<< — FasterCSV
- #== — FasterCSV::Row
- #== — FasterCSV::Table
- #FCSV — Object
- #FasterCSV — Object
- #[] — FasterCSV::Row
- #[] — FasterCSV::Table
- #[]= — FasterCSV::Row
- #[]= — FasterCSV::Table
- #add_row — FasterCSV
- #by_col — FasterCSV::Table
- #by_col! — FasterCSV::Table
- #by_col_or_row — FasterCSV::Table
- #by_col_or_row! — FasterCSV::Table
- #by_row — FasterCSV::Table
- #by_row! — FasterCSV::Table
- #convert — FasterCSV
- #delete — FasterCSV::Row
- #delete — FasterCSV::Table
- #delete_if — FasterCSV::Table
- #delete_if — FasterCSV::Row
- #each — FasterCSV::Table
- #each — FasterCSV::Row
- #each — FasterCSV
- #field — FasterCSV::Row
- #field? — FasterCSV::Row
- #field_row? — FasterCSV::Row
- #fields — FasterCSV::Row
- #gets — FasterCSV
- #header? — FasterCSV::Row
- #header_convert — FasterCSV
- #header_row? — FasterCSV
- #header_row? — FasterCSV::Row
- #header_row? — FasterCSV
- #headers — FasterCSV::Row
- #headers — FasterCSV::Table
- #include? — FasterCSV::Row
- #index — FasterCSV::Row
- #inspect — FasterCSV
- #inspect — FasterCSV::Table
- #inspect — FasterCSV::Row
- #inspect — FasterCSV
- #method_missing — FasterCSV
- #parse_csv — String
- #push — FasterCSV::Row
- #push — FasterCSV::Table
- #puts — FasterCSV
- #read — FasterCSV
- #readline — FasterCSV
- #readlines — FasterCSV
- #rewind — FasterCSV
- #shift — FasterCSV
- #to_a — FasterCSV::Table
- #to_csv — Array
- #to_csv — FasterCSV::Table
- #to_csv — FasterCSV::Row
- #to_hash — FasterCSV::Row
- #to_s — FasterCSV::Table
- #to_s — FasterCSV::Row
- #values_at — FasterCSV::Row
- #values_at — FasterCSV::Table

[Validate]

Generated with the Darkfish Rdoc Generator 2.