lib/sycsvpro/spread_sheet.rb
def rows_from_params(opts)
        col_count = opts[:cols] 
        row_count = opts[:rows]
        
        size = row_count * col_count if row_count && col_count

        rows = []

        if values = opts[:values] 
          if size
            values += [NotAvailable] * (size - values.size)
          elsif col_count
            values += [NotAvailable] * ((col_count - values.size) % col_count)
          elsif row_count
            values += [NotAvailable] * ((row_count - values.size) % row_count)
            col_count = values.size / row_count
          else
            col_count = Math.sqrt(values.size).ceil
            values += [NotAvailable] * ((col_count - values.size) % col_count)
          end
          values.each_slice(col_count) { |row| rows << row }
        elsif opts[:file]
          File.foreach(opts[:file]) do |line| 
            next if line.chomp.empty?
            values = line.split(SEMICOLON) rescue str2utf8(line).split(SEMICOLON)
            rows << values.collect { |v| 
              v.strip.empty? ? NotAvailable : str2num(v.chomp, opts[:ds])
            }
          end
        end

        rows
      end
def rows_from_params(opts)
        col_count = opts[:cols] 
        row_count = opts[:rows]
        
        size = row_count * col_count if row_count && col_count

        rows = []

        if values = opts[:values] 
          if size
            values += [NotAvailable] * (size - values.size)
          elsif col_count
            values += [NotAvailable] * ((col_count - values.size) % col_count)
          elsif row_count
            values += [NotAvailable] * ((row_count - values.size) % row_count)
            col_count = values.size / row_count
          else
            col_count = Math.sqrt(values.size).ceil
            values += [NotAvailable] * ((col_count - values.size) % col_count)
          end
          values.each_slice(col_count) { |row| rows << row }
        elsif opts[:file]
          File.foreach(opts[:file]) do |line| 
            next if line.chomp.empty?
            values = line.split(SEMICOLON) rescue str2utf8(line).split(SEMICOLON)
            rows << values.collect { |v| 
              v.strip.empty? ? NotAvailable : str2num(v.chomp, opts[:ds])
            }
          end
        end

        rows
      end
Creates rows from provided array or file. If array doesn't provide
 equal column sizes the array is extended with NotAvailable values