xlsread and empty cell

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

xlsread and empty cell

turbofib
This post was updated on .
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)
thank                



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


Reply | Threaded
Open this post in threaded view
|

Re: xlsread and empty cell

PhilipNienhuis
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


Reply | Threaded
Open this post in threaded view
|

Re: xlsread and empty cell

Doug Stewart-4


On Thu, Feb 14, 2019 at 2:30 PM PhilipNienhuis <[hidden email]> 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 | Threaded
Open this post in threaded view
|

Re: xlsread and empty cell

PhilipNienhuis
Doug Stewart-4 wrote
> On Thu, Feb 14, 2019 at 2:30 PM PhilipNienhuis &lt;

> pr.nienhuis@

> &gt;
> 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
> }
>
>
> --
> DAS[image: Certificate for 206392]
>
> &lt;https://linuxcounter.net/user/206392.html&gt;

Looks good, Doug, that is odsread.m does what I'd expect it to do.

turbofib writes "empty" where he apparently refers to an empty spreadsheet
cell (with nothing inside) where your outer cells (top and bottom of the
range) seem to contain contain the numbers 2 and 7, resp.
Plus you didn't specify the 5th options argument.

P.




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


Reply | Threaded
Open this post in threaded view
|

Re: xlsread and empty cell

turbofib
thank you PhilipNienhuis

it's a bit complicated but now it's run correcty



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