There is a logical problem too, the insides of elseif can't never be reached since it will always hit the first one. If there is a fluid that is under the "1000" fuel_value limit, it will go to the elseif part and then fail.
I modded the data.lua and changed:
data.raw.fluid["heavy-oil"].fuel_value = "0.1KJ" -> crash
data.raw.fluid["heavy-oil"].fuel_value = "1000MJ" -> Works but 10000000KJ or something inside the wiki, not MJ like it should be.
I patched the scripts/wiki.lua like this so it also fixes the problem and formats the numbers correctly
if fluid_num < 1000 then
num = fluid_num .. "J"
elseif fluid_num >= 1000 and fluid_num < 100000 then
num = fluid_num/1000 .. 'KJ'
else
num = fluid_num/1000000 .. 'MJ'
end