textscan (...) can't read data with NA fields

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

textscan (...) can't read data with NA fields

Matthias Brennwald
Hello

I need to read an ASCII data file, where missing data values are given as NA. Using textscan to parse the file does not work; it seems to stop reading/parsing at the first occurrence of NA.

Here's a simple demonstration of the problem:

> x = textscan ( "1 ; 2 ; 3\n4 ; NA ; 6" , '%d %d %d' , 'Delimiter' , ';' , 'ReturnOnError' , false )
error: textscan: Read error in field 2 of row 2

I have also tried to tell textscan to treat NA as "empty value", but no luck:
     x = textscan("1 ; 2 ; 3\n4 ; NA ; 6",'%d %d %d','Delimiter',';','TreatAsEmpty','NA','ReturnOnError',false )



-----------------------------------------
Join us March 12-15 at CERN near Geneva
Switzerland for OctConf 2018.  More info:
https://wiki.octave.org/OctConf_2018
-----------------------------------------