lib/sycsvpro/calculator.rb
def method_missing(id, *args, &block)
      return to_number(columns[$1.to_i]) if id =~ /c(\d+)/
      return to_date(columns[$1.to_i])   if id =~ /d(\d+)/
      return columns[$1.to_i]            if id =~ /s(\d+)/
      super
    end
def method_missing(id, *args, &block)
      return to_number(columns[$1.to_i]) if id =~ /c(\d+)/
      return to_date(columns[$1.to_i])   if id =~ /d(\d+)/
      return columns[$1.to_i]            if id =~ /s(\d+)/
      super
    end
def method_missing ( id , * args , & block ) return to_number ( columns [ $1 . to_i ] ) if id =~ / \d / return to_date ( columns [ $1 . to_i ] ) if id =~ / \d / return columns [ $1 . to_i ] if id =~ / \d / super end
Creates a new Calculator. Optionally a header can be provided. The header
 can be supplemented with additional column names that are generated due
 to an arithmetic operation that creates new columns
 :call-seq:
   Sycsvpro::Calculator.new(infile:       "in.csv",
                            outfile:      "out.csv",
                            df:           "%d.%m.%Y",
                            rows:         "1,2,BEGINn3>20END",
                            header:       "*,Count",
                            final_header: false,
                            cols:         "4:c1+c2*2",
                            write:        "1,3-5",
                            sum:          true).execute
 infile:: File that contains the rows to be operated on
 outfile:: Result of the operations
 df:: Date format
 rows:: Row filter that indicates which rows to consider
 header:: Header of the columns
 final_header:: Indicates that if write filters columns the header should
 not be filtered when written
 cols:: Operations on the column values
 write:: Columns that are written to the outfile
 sum:: Indicate whether to add a sum row
 Retrieves the values from a row as the result of a arithmetic operation
 with #eval
Creates a new Calculator . Optionally a header can be provided . The header can be supplemented with additional column names that are generated due to an arithmetic operation that creates new columns : call - seq : Sycsvpro :: Calculator . new ( infile : in . csv outfile : out . csv df : %d . %m . %Y rows : 1 2 BEGINn3 > 20END header : * Count final_header : false cols : 4 : c1 + c2 * 2 write : 1 3 - 5 sum : true ) . execute infile :: File that contains the rows to be operated on outfile :: Result of the operations df :: Date format rows :: Row filter that indicates which rows to consider header :: Header of the columns final_header :: Indicates that if write filters columns the header should not be filtered when written cols :: Operations on the column values write :: Columns that are written to the outfile sum :: Indicate whether to add a sum row Retrieves the values from a row as the result of a arithmetic operation with #eval