table

table(path, options = Hash.new) Class Public methods A shortcut for: CSV.read( path, { headers: true, converters: :numeric, header_converters: :symbol }.merge(options) )

readlines

readlines(*args) Class Public methods Alias for ::read.

read

read(path, *options) Class Public methods Use to slurp a CSV file into an Array of Arrays. Pass the path to the file and any options ::new understands. This method also understands an additional :encoding parameter that you can use to specify the Encoding of the data in the file to be read. You must provide this unless your data is in Encoding.default_external. CSV will use this to determine how to parse the data. You may provide a second Encoding to have the data transcoded as

parse_line

parse_line(line, options = Hash.new) Class Public methods This method is a shortcut for converting a single line of a CSV String into a into an Array. Note that if line contains multiple rows, anything beyond the first row is ignored. The options parameter can be anything ::new understands.

parse

parse( str, options = Hash.new ) { |row| ... }parse( str, options = Hash.new ) Class Public methods This method can be used to easily parse CSV out of a String. You may either provide a block which will be called with each row of the String in turn, or just use the returned Array of Arrays (when no block is given). You pass your str to read from, and an optional options Hash containing anything ::new understands.

open

open( filename, mode = "rb", options = Hash.new ) { |faster_csv| ... }open( filename, options = Hash.new ) { |faster_csv| ... }open( filename, mode = "rb", options = Hash.new )open( filename, options = Hash.new ) Class Public methods This method opens an IO object, and wraps that with CSV. This is intended as the primary interface for writing a CSV file. You must pass a filename and may optionally add a mode for Ruby's open(). You may also pass an optional Hash containing any op

new

new(data, options = Hash.new) Class Public methods This constructor will wrap either a String or IO object passed in data for reading and/or writing. In addition to the CSV instance methods, several IO methods are delegated. (See ::open for a complete list.) If you pass a String for data, you can later retrieve it (after writing to it, for example) with CSV.string(). Note that a wrapped String will be positioned at at the beginning (for reading). If you want it at the end (for

instance

instance(data = $stdout, options = Hash.new) Class Public methods This method will return a CSV instance, just like ::new, but the instance will be cached and returned for all future calls to this method for the same data object (tested by Object#object_id) with the same options. If a block is given, the instance is passed to the block and the return value becomes the return value of the block.

generate_line

generate_line(row, options = Hash.new) Class Public methods This method is a shortcut for converting a single row (Array) into a CSV String. The options parameter can be anything ::new understands. This method understands an additional :encoding parameter to set the base Encoding for the output. This method will try to guess your Encoding from the first non-nil field in row, if possible, but you may need to use this parameter as a backup plan. The :row_sep option defaults to $INP

generate

generate( str, options = Hash.new ) { |csv| ... }generate( options = Hash.new ) { |csv| ... } Class Public methods This method wraps a String you provide, or an empty default String, in a CSV object which is passed to the provided block. You can use the block to append CSV rows to the String and when the block exits, the final String will be returned. Note that a passed String is modfied by this method. Call dup() before passing if you need a new String. The options parameter ca