What is the correct file extension for function "importdata" working properly?

2 views (last 30 days)
Hello, Recently I am running a script in which it imports a data text file "result.rpt" into a cell array by function "importdata". The script run perfectly some time ago when it was compiled (before R2013), but fails this time on the version R2014b. It only generates an empty array. But when I rename the file to "result.dat", the "importdata" can function properly.
E.g.,
The file "result.rpt" contains:
HEAD LINE 1
HEAD LINE 2
NAME-A 1 2 3 4
NAME-B 5 6 7 8
And if I type in:
[a,b,c]=importdata('result.rpt', ' ', 2)
it will create:
a = []
b = []
c = []
And,
The file "result.dat" contains:
HEAD LINE 1
HEAD LINE 2
NAME-A 1 2 3 4
NAME-B 5 6 7 8
And if I type in:
[a,b,c]=importdata('result.dat', ' ', 2)
it will create:
a =
data: [2x4 double]
textdata: {4x1 cell}
b =
c = 2
Therefore, I would like to ask if there is any limitation about the function "importdata" on file extensions after R2014b? Is the function changed to a limited range of extension and refuses to read in other type of files?
Thanks a lot!!
Yaoguang

Answers (2)

dpb
dpb on 30 Jul 2015
If this is indeed reproducible and can be absolutely confirmed to be the file name extension only, it's a bug. Submit a bug report to TMW at www.mathworks.com
documents nothing re: '.rpt' as a special file extension for latest version.
I'm sure TMW will tell you the workaround is to temporarily rename the file if it is, indeed, so(*) for the time being.
(*) And I'm not saying it isn't, just saying if by any remote chance there is something else going on you haven't quite recognized yet...

Walter Roberson
Walter Roberson on 30 Jul 2015
If you read between the lines there, noticing that "any" file extension is supported for audioread and VideoReader, you can see that multiple attempts are going to be made to load the file using helper functions; if one of those helper functions does not error out and instead returns empty then you would get the result you observe.
  1 Comment
dpb
dpb on 30 Jul 2015
I've not dug thru the logic internal to importdata but seems like TMW must've changed the search order or something to see different behavior.
It's that nebulous operation and excessive overhead as opposed to just opening the specific file that's always made me stay away from these generic functions albeit I understand TMW's desire for the convenience of trying to make it so the user doesn't need to know anything.
Not sure there's any foolproof method altho giving up and returning with empty if haven't yet tried simple ASCII doesn't sound like "the right stuff" solution.

Sign in to comment.

Categories

Find more on Environment and Settings in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!