< :the previous in number
^ :the list in numerical order
> :the next in number
P :the previous artilce (have the same parent)
N :the next (in thread)
|<:the top of this thread
>|:the next thread
^ :the parent (reply-to)
_:the child (an article replying to this)
>:the elder article having the same parent
<:the youger article having the same parent
---:split window and show thread lists
| :split window (vertically) and show thread lists
~ :close the thread frame
.:the index
..:the index of indices
Snoopy Dog schrieb:
> Sam Gentle wrote:
>>
>> require 'enumerator'
>>
>> data = File.readlines(path)
>> additional_data = File.readlines(second)
>> data.concat(additional_data)
>>
>> data.sort!
>> mergeddata = [data[0]]
>> 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