From: botp Date: 2011-10-06T14:23:44+09:00 Subject: Re: comparing elements in same array On Thu, Oct 6, 2011 at 12:04 PM, Thomas Le wrote: > I want to find (thousands of) duplicate names in the spreadsheet so I can > compare the corrresponding files to see if they produce the same results ... ok > my logic is like this "if name in column A row 2 is same as that in colum A > row 3, open files in column B row 2 and column B row 3,...do something else" column A is already name column. files of the same pathname are the same. compare only if they have different pathnames. you can try something like, #---start code require 'roo' ORGFILE = 'organize.xlsx' xcel = Excelx.new(ORGFILE) xcel.default_sheet = xcel.sheets.first startingRow = 2 nameProfile = Hash.new { |h, k| h[k] = [] } startingRow.upto(xcel.last_row) do |row| name = xcel.cell(row,'A') location = xcel.cell(row,'B') nameProfile[name] << location startingRow += 1 end nameProfile.delete_if{|k,v| v.unique.size>1} #---end code nameProfile should only contain hash of names with multiple pathnames note, code above untested since i do not have your actual file. try it in irb. kind regards -botp