foreach

foreach(path, options = Hash.new, &block) Class Public methods This method is intended as the primary interface for reading CSV files. You pass a path and any options you wish to set for the read. Each row of file will be passed to the provided block in turn. The options parameter can be anything ::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

filter

filter( options = Hash.new ) { |row| ... }filter( input, options = Hash.new ) { |row| ... }filter( input, output, options = Hash.new ) { |row| ... } Class Public methods This method is a convenience for building Unix-like filters for CSV data. Each row is yielded to the provided block which can alter it as needed. After the block returns, the row is appended to output altered or not. The input and output arguments can be anything ::new accepts (generally String or IO objects). If

values_at

values_at(*indices_or_headers) Instance Public methods The mixed mode default is to treat a list of indices as row access, returning the rows indicated. Anything else is considered columnar access. For columnar access, the return set has an Array for each row with the values indicated by the headers in each Array. You can force column or row mode using #by_col!() or #by_row!(). You cannot mix column and row access.

to_s

to_s(options = Hash.new) Instance Public methods Alias for: to_csv

to_csv

to_csv(options = Hash.new) Instance Public methods Returns the table as a complete CSV String. Headers will be listed first, then all of the field rows. This method assumes you want the #headers, unless you explicitly pass :write_headers => false. to_s

to_a

to_a() Instance Public methods Returns the table as an Array of Arrays. Headers will be the first row, then all of the field rows will follow.

push

push(*rows) Instance Public methods A shortcut for appending multiple rows. Equivalent to: rows.each { |row| self << row } This method returns the table for chaining.

inspect

inspect() Instance Public methods Shows the mode and size of this table in a US-ASCII String.

headers

headers() Instance Public methods Returns the headers for the first row of this table (assumed to match all other rows). An empty Array is returned for empty tables.

each

each(&block) Instance Public methods In the default mixed mode or row mode, iteration is the standard row major walking of rows. In column mode, interation will yield two element tuples containing the column name and an Array of values for that column. This method returns the table for chaining.