csv import - Ruby display every element -
in section of code below trying extract column csv stored in @record.main_id. splitting code gain every comma separated value , store in mysql table table_val in column id. need every instance of main_id loaded id instead repeated values not getting loaded. example 2,3,4,6,4,6,8. need every instance in sequence instead values getting loaded 2,3,4,6,8.
def get_id @record.main_id.split(', ').map |f| values = { id: f } @att = table_val.new(values) end
how :
def get_id @record.main_id.split(', ').sort.uniq.map |f| values = { id: f } @att = table_val.new(values) end check document more info uniq , sort.
Comments
Post a Comment