help-octave
[Top][All Lists]
Advanced

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

Re: Textscan Stops for Missing Data


From: PhilipNienhuis
Subject: Re: Textscan Stops for Missing Data
Date: Sun, 3 Sep 2017 07:34:38 -0700 (MST)

gciriani wrote
> 
> PhilipNienhuis wrote
>> ... when I tried it turned out it couldn't read you file either, while
>> AFAICS it should be able to (nothing wrong with the file)
>> I'll look into that.
> Thank you! For the time being I'm able to circumvent the problem by
> pre-processing my data in Excel (i.e. adding a recognizable number, such
> as 999, to occurrences of blank cells). But it would be great to be able
> to deal with it directly in Octave in the future.

Hi,

(coming back to this)

I looked into your issue because I feared a bug in csv2cell(). Luckily that
works fine AFAICS.

However it appears that your tab-delimited text file is a bit messy:

Lines 3, 4 and 6 contain a leading TAB character. That should be no problem
per se, but as it is an extra delimiter (unintended or not) textscan gets
out-of-sync as it assumes a data field before the leading TAB.
Lines 1, 4, and 6 to 14 also have a *trailing* tab. That confuses textscan()
even more.

In fact textscan (and csv2cell) see 17 rather than 16 data columns in lines
1 and 7-14 (the 17th behind the trailing TAB characters, but empty), and
even 18 (the first before the leading TAB) in lines 4 and 6.
All that makes it hard for a picky program like textscan to do as you
instructed :-)

I suppose you could instruct textscan to skip trailing stuff by adding a
"*[^\n]" format specifier after the last one, telling it to skip any
characters after the last field ("column") you want to read until EOL.
Still, you'll see that it gets out-of-sync on lines 3, 4 and 6.

So I'd really suggest to clean up the program that created the exlong.tab
file in the first place, it could save you quite a bit of trouble :-)

BTW a hint:
I used notepad++ to read exlong.tab and made it show White Space and Tab in
View | Show Symbols

Philip




--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html



reply via email to

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