help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Reading data with NA values using textscan(...)


From: Matthias Brennwald
Subject: Reading data with NA values using textscan(...)
Date: Thu, 8 Feb 2018 19:40:21 +0100

Hello

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

Here's a simple demonstration of the issue:
     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 interpret NA as "empty", but no luck:
     x = textscan ( "1 ; 2 ; 3\n4 ; NA ; 6" , '%d %d %d' , 'Delimiter' , ';' , 'TreatAsEmpty' , 'NA' , 'ReturnOnError' , false )
     error: textscan: Read error in field 2 of row 2

Can someone explain what's going on, or how to make this work?

(I am running Octave 4.2.1)

Thanks
Matthias

reply via email to

[Prev in Thread] Current Thread [Next in Thread]