1
votes

I want to import kddcup dataset in matlab. When I import this dataset:

fid = fopen('kddcup.testdata','rt');
data = textscan(fid,['%d %s %s %s ', repmat('%f ',1,37), '%s'], 'delimiter',',');
fclose(fid);

And I get this error:

Error using textscan
Invalid file identifier. Use fopen to generate a valid file identifier.

What is wrong in this code?

1
what is the extension .testdata? Is this the extension of the file? - EBH
No, ".testdata" is not the extension. It is just a file name . - guptashekhar54

1 Answers

0
votes

My guess is that Matlab doesn't find the file you specify.

Note that you should type a full name, including the extension (e.g. 'myfile.txt') and make sure it's in your current directory (otherwise, you have to write the full path).

If you call fopen correctly, then fid should have an integer number, otherwise it returns -1. You should chek that too.