lib/torqml/datasources/csvdatasource.rb
# Prepare data to provide.
# The separator of CSV data can be set via `:separator` property.
# If not set, the method tries to detect it automatically.
Prepare data to provide.
The separator of CSV data can be set via `:separator` property.
If not set, the method tries to detect it automatically.
Prepare data to provide . The separator of CSV data can be set via ` : separator ` property . If not set the method tries to detect it automatically .
def prepare_data
        if self.separator.empty?
          File.open(self.source, "r") do |file|
            row = file.readline
            if row.match(/,/)
              self.separator = ','
            elsif row.match(/\t/)
              self.separator = '\t'
            elsif row.match(/\s/)
              self.separator = ' '
            end
          end
        end
        @data = CSV.read(self.source, {:converters => :float, :col_sep => self.separator})
      end
def prepare_data if self . separator . empty? File . open ( self . source , "r" ) do | file | row = file . readline if row . match ( / , / ) self . separator = ',' elsif row . match ( / \t / ) self . separator = '\t' elsif row . match ( / \s / ) self . separator = ' ' end end end @data = CSV . read ( self . source , { :converters => :float , :col_sep => self . separator } ) end
Prepare data to provide.
Prepare data to provide .
# detect the separator of data