Skip to main content

import - Why ReadList ignores NullRecords for Number?


When thinking on this recent question the immediately obvious solution which came to my mind was to use ReadList with options RecordLists -> True and NullRecords -> True for reading objects of type Number. But I discovered that NullRecords -> True is ignored for Number although RecordLists -> True is respected:


ReadList[StringToStream["1 2 3\n4 5\n\n6 7\n8 9"], Number, RecordLists -> True, 
NullRecords -> True]



{{1, 2, 3}, {4, 5}, {6, 7}, {8, 9}}

Currently the option NullRecords -> True is respected only for types Record and String:


ReadList[StringToStream["1 2 3\n4 5\n\n6 7\n8 9"], String, RecordLists -> True, 
NullRecords -> True]


{{"1 2 3"}, {"4 5"}, {""}, {"6 7"}, {"8 9"}}


ReadList[StringToStream["1 2 3\n4 5\n\n6 7\n8 9"], Record, RecordLists -> True, 
NullRecords -> True]


{{"1 2 3"}, {"4 5"}, {""}, {"6 7"}, {"8 9"}}

It is interesting that in version 5.2 this option was respected also for objects of type Word (but not for Number and Real):


$Version
ReadList[StringToStream["1 2 3\n4 5\n\n6 7\n8 9"], Word, RecordLists -> True,
NullRecords -> True]



"5.2 for Microsoft Windows x86 (64 bit) (June 20, 2005)" 
{{"1", "2", "3"}, {"4", "5"}, {}, {"6", "7"}, {"8", "9"}}

The ignorance of NullRecords -> True for Number makes no sense for me, especially considering that RecordLists -> True is respected. Is there any reason for this? Is it a bug?




Comments