Your suggestion worked. However, the ip 0.0.0.0, which did not exist in the file, was added. There were no empty lines.
The :deserialize is very new, so it may a bug in that actually. i.e. inserting an extra array element, that would unconverted to an IP type, which defaults to 0.0.0.0.
Do you have a sample file you can post?
But I think this should protect against that case:
{
:local filebody [/file/get iplist.txt contents]
:local addressListName "MyAddressList"
:local expire 1h
:foreach ip in=[ :deserialize [:tolf $filebody] delimiter="\n" from=dsv options=dsv.plain ] do={
/log debug "adding $ip to $addressListName"
:if ([:tostr $ip] != "0.0.0.0") do={
:onerror e in={
/ip firewall address-list add list=$addressListName address=$ip timeout=$expire
} do={/log debug "skipping $ip ($e)"}
}
}
}
(updated with error checking for duplicates)
The "old school" way of doing this is to read each char using [:pick] and using two arrays to store, one for the currently in-progress parse one, and another a list of all IP found (when a \n is the char found in buffer). There is nothing like a readline() from file in RouterOS otherwise.