@Mickel
I might have some further optimization for you (I now kinda see what you're trying to do). You can loop the rows with your outer loop. For your inner loop you only need to loop from the same place as your outer loop until you find your year or until you find another value. In this case you won't need the extra k variable and the loop is terminated much faster in comparison to your code.
(From your Example.csv the inner loop for rows 1004 only has to loop from current row until the column 1 changes to something else than 1004.)
for i := 1 to matrix1.NrRows do //119533
begin
for j := i to matrix1.NrRows do // <-- you can begin at row i
begin
if matrix1[i, 1] = matrix1[j, 1] then // gck the same
begin
if matrix1[j, 2] = matrix1[i, 2] - 1 then
begin
writeln(i);
matrix1.SetCell(i, 4, matrix1[j, 3]);
break;
end;
end
else
break; // you can break here because you've reached another value
end;
end;
About your conversion to integermatrix.... How do you read those real values. Or have you changed the source file to cents instead of euros?
If you still have euros you can't read anything other then whole euros.
I also found it strange you got +E03 because I saw this line in the source:
Str(PDouble(@value)^:5:2, text);
which should have resulted in a number like 12345.12
(So maybe it's better to concentrate on fixing that than going for integermatrix)
But if you integermatrix works for you it's ok (but if you're dealing with currency I still think you'll need the realmatrix).
One final note... besides the suggestion wp made about placing the code in the code-tags... you also might want to use correct and easy to read indentation. It was the incorrect indentation that got you in problems with your previous assets() procedure. If the indentation is correct, errors are much easier to spot.
If you have Lazarus you can install the package jclidelazarus. After that you can use Ctrl+D to run a code-formatter which does the indentation for you. It's really easy and convenient.