Extract two values from a merged column in excel using ruby code

Viewed 39

I am very new to ruby code. Need your help !!

I have an excel as below:

enter image description here

I can extract columns value since 1 col has 1 value. Now I have my excel changed to this

enter image description here

This was the old code:

def getMapLine(tgId)
    mappingFile = File.open("#{$mapPath}","r")
    foundEntry = false
    while(line = mappingFile.gets)
        line.chomp!
        tbData = line.split(',')
        rdId = tbData[1].to_i
        if(rdId == tgId)
            puts "Found Line in CSV with Expected ID:ReadID = #{rdId}   TgtId = #{tgId}"
            foundEntry = true
            configLine = line
        end
    end
    if(foundEntry == false)
        raise "ERROR!!! Did not find an entry for target Id: #{tgId}"
    end
    mappingFile.close
    return configLine
end

def getMapping(Id, mapHash)
    mapLine = getMapLine(Id)
    tbData = mapLine.split(',')
    for i in 3..6
        if(tbData[i].downcase != "x")
            mapHash[i-2] = tbData[i]
        end
    end  
end

I am not understanding how to extract now. since each col has two values now and I need both values further in my code. What should I change in the above code?

0 Answers
Related