This is a very peculiar way of writing the loop, which makes it hard to see what’s going on, but it seems like you are basically trying to replace values in stock
with values in flow
if they are different now but were the same before?
Some comments:
for v = 1:length(flow[:,1])
Here it would be idiomatic to use size(flow, 2)
if isempty(findall(x->x==flow[v,1], stock[:,1])) == false
...
end
if isempty(findall(x->x==flow[v,1], stock[:,1])) == true
...
end
Here you are unnecessarily performing the findall
check twice, when it can only be either true or false. You could just use if ... else ... end
to write:
if !isempty(findall(x->x==flow[v,1], stock[:,1]))
...
else
...
end
id = findall(x->x==flow[v,1], stock[:,1])
Here you are performing the check for a third time, which tells me you should have just saved the result the first time around.
I would probably write something like this (note this hasn’t been tested of course!)
for v = 1:size(flow, 2)
matches = flow[v, 1] .== stock[:, 1]
if sum(matches) > 0
stock[matches, 2] .= flow[v, 2]
else
stock = [permutedims(flow[v,:]);stock]
end
end