help-octave
[Top][All Lists]
Advanced

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

Re: xlsread and empty cell


From: Doug Stewart
Subject: Re: xlsread and empty cell
Date: Thu, 14 Feb 2019 14:42:22 -0500



On Thu, Feb 14, 2019 at 2:30 PM PhilipNienhuis <address@hidden> wrote:
turbofib wrote
> hi guys,
>
> i try to read cell excel :
>
> [ a, b, c] = xlsread (percorsoNomeFile,1,'A2:A7'); 
>
> there is 6  boxes excel
>
> it read from excel:
>
>  A2="xxx";
>  A3="xxx";
>  A4="xxx";
>  A5=empty;
>  A6="xxx";
>  A7="empty";
>
> now i print it:
>
> c=
> [1,1] = xxx
>   [2,1] = xxx
>   [3,1] = xxx
>   [4,1] = "   "
>    [5,1] =xxx
>
> there is n. 5  element not 6
>
> how can i avoid to delete 1 element? 
> (i would like to read n.6 element ..no 5)

Octave's xlsread strips empty outer columns and rows by default. In return
it gives a fourth (or fifth) output ("limits" below) that tells you from
which part of the sheet your numeric and textual data came from.
If you don't want that you'd have to specify an option, see "help xlsread"
and "help xls2oct" (admittedly it's a bit of searching in the long help
texts).
Something along the lines of:

[num, txt, raw, limits] = xlsread (<Excel file name>, <sheet name>, <range>,
<interface>, options)

In your case I suppose the following should work:

opts = struct ("strip_array", 0);   ## Value is a numeric zero, or "false"
[ a, b, c] = xlsread (percorsoNomeFile, 1, 'A2:A7', '', opts);

Note the empty string between range and options.

Maybe this can be set as an alias in your .octaverc; I never tried.

Please report back if the above solves your problem.

Philip




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



I just tried this in Ubutu 18.10 and octave rc2 and io2.4.12


[ a, b, c] = xlsread ("calcfile.ods",1,'A2:A7')

Detected XLS interfaces: a =

     2
     3
     4
   NaN
     6
     7

b = {}(0x0)
c =
{
  [1,1] =  2
  [2,1] =  3
  [3,1] =  4
  [4,1] = [](0x0)
  [5,1] =  6
  [6,1] =  7
}


--
DASCertificate for 206392


reply via email to

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