A moderator merged this question with this question - that's why it looks a little messy here. This answer considers additional issues in the second question!
The following is not an entirely clean solution, the code is adopted from my previous answer, but I added an exception for your case, so you don't need to delete values at the beginning and/or end of your data manually. It discards only these invalid values, that shouldn't cause problems.
Af = csvread(strcat('example_data_with_peak.txt'),5,0);
% Thresholds
Tl = -0.04;
To = 0.04;
% initialisation
peaks = find( Af < Tl | Af > To);
counter = 0;
while ~isempty(peaks)
peaks = find( Af < Tl | Af > To);
try
Af(peaks) = ( Af(peaks-1) + Af(peaks+1) ) / 2;
catch
if peaks(1) == 1
Af(1) = 0;
else
Af(end) = 0;
end
end
counter=counter+1;
end
figure(2);
plot(Af)

For determining the threshold you could use somethink like this, but it's also quite brute-force:
thresh = 15*mean(abs(findpeaks(Af)));