There are many CSV/FTP examples on the forum. There's also example on our website: https://openrb.com/example-export-last-h...-from-lm2/
As for the difference calculation it should be done on numeric values not on the strings that are formatted using the numeric values. Then you can simply subtract one value from another.
Please describe exactly what do you want to compare and post the code that you use. Most likely you already have a numeric value before it's converted to a formatted string that is written to 250 byte object.
-----------------Common Function----------------------------
function formattime(output, seconds)
local minutes = math.floor(seconds / 60)
local hours = math.floor(minutes / 60)
local days = math.floor(hours / 24)
local res = {}