I have a ruby import to DB process that checks header titles against an array called headers. As it stands right now, those headers must be typed exactly the same as they appear in the array. I would like for them to be accepted regardless if they are upper or lowercase.
CSV.foreach(FILE, encoding:'iso-8859-1:utf-8', headers: true, skip_blanks: true) do |row|
# check the header row, make sure all are acceptable
if count == 0
row.headers.each do |header|
if (!headers.include? header) and !header.nil? and header != ""
log.error "#{header} is not a valid header"
exit
end
end
end
Currently accepts: "Ast_A" But does not accept: "ast_a" I have tried code from Convert hash keys to lowercase -- Ruby Beginner to no avail. My question is how do I make the .csv import header row case insensitive during the import?