octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #61313] importdata fails on reading an ascii f


From: Markus Mützel
Subject: [Octave-bug-tracker] [bug #61313] importdata fails on reading an ascii file
Date: Sat, 9 Oct 2021 09:49:27 -0400 (EDT)
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.71 Safari/537.36 Edg/94.0.992.38

Update of bug #61313 (project octave):

                  Status:                    None => Confirmed              

    _______________________________________________________

Follow-up Comment #1:

I can confirm that this doesn't work.

Fwiw in Matlab R2021a:

>> a=importdata('data.txt', ' ', 1)

a = 

        data: [-21.2280 -0.9760 -979.6600 2520 -4060 560 -602096 -13684
-27463788 6.0006e+05 35.1642 1.8442e+06]
    textdata: {2x1 cell}

>> a.textdata

ans = 

    't (s)           acc_x (mg)      acc_y (mg)      accy_z (mg)    w_x (mdps)
     w_y (mdps)      w_z (mdps)      b_x (mG)        b_y (mG)       b_z (mG)  
     p (Pa)          T (deg C)       h (m)         '
    '03:00:21.550'


IIUC, `importdata` with ' ' as a separator calls `dlmread` with empty
separator to read the numeric portion of the data. That corresponds to calling
`dlmread` like this:

dlmread ('data.txt', "", 1, 1, "emptyvalue", NA);


My guess is that `dlmread` tries to guess a separator in this case, finds ':'
before any other choices (",:; \t"), and continues using that as the
separator.
That messes up reading the file.

If you know the structure of the file you'd like to read beforehand, you could
use something like the following as a workaround:

fid = fopen('data.txt');
a = textscan(fid, '%s %f %f %f %f %f %f %f %f %f %f %f %f', 'HeaderLines', 1,
'Delimiter', ' ')
fclose(fid);



    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?61313>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

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