bugGNU Octave - Bugs: bug #61313, importdata fails on reading an...


bug #61313: importdata fails on reading an ascii file

Submitted by:  None
Submitted on:  Sat 09 Oct 2021 07:15:27 AM UTC  
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Unexpected Error or Warning
Status:  Confirmed Assigned to:  None
Originator Name:  TB Originator Email:  -email is unavailable-
Open/Closed:  Open Release:  6.3.0
Operating System:  Microsoft Windows

Add a New Comment (Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


Tue 12 Oct 2021 04:34:39 PM UTC, comment #2: 

Could the reporter upload a file with the first two text lines?  I'd like to verify the behavior.  It seems to be different between version 6.3 and the development branch (version 7.0).

Rik <rik5>
Project Administrator
Sat 09 Oct 2021 01:49:26 PM UTC, 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)         '

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', ' ')

Markus M├╝tzel <mmuetzel>
Project Member
Sat 09 Oct 2021 07:15:27 AM UTC, original submission:  

Failure on the import of ASCII file. Header and first line of file are pasted below. I believe that impordata chokes because of the format of the time string in the first column?

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    -21.228001      -0.976000       -979.660034     2520.000000     -4060.000000    560.000000      -602096.000000  -13684.000000   -27463788.000000 600056.062500   35.164249      1844192.500000

Error is:

error: missing_idx(13): out of bound 3 (dimensions are 1x3)
error: called from
    importdata>importdata_ascii at line 281 column 21
    importdata at line 133 column 40



(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by mmuetzel (Posted a comment)
  • -email is unavailable- added by None (Submitted the item)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.




    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-10-09 mmuetzel StatusNone => Confirmed

    Back to the top

    Powered by Savane 3.7