Pit Capitain wrote: > Snoopy Dog schrieb: >>> data.each_cons(2) {|x1,x2| mergeddata.push(x2) unless x1.split(/,/)[1] >>> == x2.split(/,/)[1]} >> >> Sam, that works great. > > Snoopy, you mentioned in one of our posts that the suppliers might > deliver inconsistent data, for example different volumes for the same > date, and Sam's solution guarantees that you get only one row for each > date. You should be aware, though, that it randomly chooses this one > row. For some data, it could be the row of the first file, for other > data it could be the row of the second file. If you want to prefer one > of the suppliers over the others, you have to implement a slightly > different algorithm. The problem is that Ruby's sort isn't a stable > sort. > > Regards, > Pit Pit, Thanks for mentioning that. I assumed that the sort kept them in order, and I used the push(x1) instead of push(x2) after a few of my tests. That way I kept the historical data. Since my sample data tests are small, I was just lucky not to have them out of the order I expected them. Now looking at Jordan's code, I think I will use (a variant) of it to control what I keep for historical data. Thanks again Pit. Snoopy -- Posted via http://www.ruby-forum.com/.