L
lfast1234
In some magical way ruby is maintaining the 'Cell' designation from my .csv data as I transform it into a yaml file. I don't want that. Any idea how i get rid of it?
Source:
location,server_env (heading line)
van,cpci (content line)
....
Desired output
fleetmanifest:
location: van
server_env: cpci
Actual Output
fleetmanifest:
? !str:CSV::Cell location
: !str:CSV::Cell van
? !str:CSV::Cell server_env
: !str:CSV::Cell cpci1
Current Transformation code
fleetH = {}
myCSV.each { |row|
# Find the header row based on 0th column
if headerrow
hd_row = row
end
if datarow
hd_row.zip(row).each { |k,v|
fleetH[k] = v
}
break
end
}
puts fleetH.class => Hash
puts fleetH.to_yaml => produces the ? !str:CSV::Cell gibberish!
Source:
location,server_env (heading line)
van,cpci (content line)
....
Desired output
fleetmanifest:
location: van
server_env: cpci
Actual Output
fleetmanifest:
? !str:CSV::Cell location
: !str:CSV::Cell van
? !str:CSV::Cell server_env
: !str:CSV::Cell cpci1
Current Transformation code
fleetH = {}
myCSV.each { |row|
# Find the header row based on 0th column
if headerrow
hd_row = row
end
if datarow
hd_row.zip(row).each { |k,v|
fleetH[k] = v
}
break
end
}
puts fleetH.class => Hash
puts fleetH.to_yaml => produces the ? !str:CSV::Cell gibberish!