0
I have a CSV file that I interpret through Smartcsv. However, I need the keys names of the generated hashes to be changed, for use I am using Smartcsv key_mapping but it is not changing the names.
A part of the original CSV file:
ID da Organização;Nome da Organização;último acesso
81;company_81;2000-01-01 00:00:00
This is the part that is made the interpretation:
file = File.open(org_file.path)
options = {
col_sep: ';',
header_transformations: [ key_mapping: {:id_da_organização => :id, :nome_da_organização => :name, :último_acesso => :last_access} ]
}
@file = SmarterCSV.process(file.path, options)
The @file hashes after this part are like this:
:id_da_organização=>81, :nome_da_organização=>"company_81", :último_acesso=>"2000-01-01 00:00:00"
But I wanted the keys to change according to what I asked.