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: siko1056
Subject: Re: Textscan Stops for Missing Data
Date: Thu, 24 Aug 2017 14:29:12 -0700 (MST)

I think in your case `textscan` has a problem with the Tab delimiter:

<code>
str = "\"1176-0\"\t5\t\"d\"\t4\n";
C = textscan (str, "%q %f %q %f","EmptyValue", NaN,"Delimiter", "\t", ...
  "ReturnOnError", true)
str = "\"1176-0\"\t\t\"d\"\t4\n";
C = textscan (str, "%q %f %q %f","EmptyValue", NaN,"Delimiter", "\t", ...
  "ReturnOnError", true)

## Replace delimiter with comma

str = "\"1176-0\",,\"d\",4\n";
C = textscan (str, "%q %f %q %f","EmptyValue", NaN,"Delimiter", ",", ...
  "ReturnOnError", true)
</code>

<output>
C =
{
  [1,1] =
  {
    [1,1] = 1176-0
  }

  [1,2] =  5
  [1,3] =
  {
    [1,1] = d
  }

  [1,4] =  4
}

C =
{
  [1,1] =
  {
    [1,1] = 1176-0
  }

  [1,2] = [](0x1)
  [1,3] = {}(0x1)
  [1,4] = [](0x1)
}

## Replace delimiter with comma

C =
{
  [1,1] =
  {
    [1,1] = 1176-0
  }

  [1,2] = NaN
  [1,3] =
  {
    [1,1] = d
  }

  [1,4] =  4
}
</output>

Maybe it is worth to file a bug report with the request to add a delimiter
test for tabs like in [1].  For a temporary fix, you can use "Find&Replace"
the Octave editor and convert you file to a comma separated value (CSV) file
by substituting Tabs with commas.

HTH,
Kai

[1]:
https://hg.savannah.gnu.org/hgweb/octave/file/e54e13ee99ce/libinterp/corefcn/file-io.cc#l1619



--
View this message in context: 
http://octave.1599824.n4.nabble.com/Textscan-Stops-for-Missing-Data-tp4684655p4684669.html
Sent from the Octave - General mailing list archive at Nabble.com.



reply via email to

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