Issue when reading csv file using textscan()
古いコメントを表示
I want to read dataset.csv in my program. I have the following code:
filename = 'dataset.csv';
delimiter = '\t';
formatSpec = '%f%f%[^\n\r]';
fileID = fopen(filename,'r');
dataArray = textscan(fileID, formatSpec, 'Delimiter', delimiter, 'ReturnOnError', false);
fclose(fileID);
However, I get this error:
Error using textscan
Invalid file identifier. Use fopen to generate a valid file identifier.
Can someone tell me the issue? I couldn't spot it!!
4 件のコメント
Nick
2017 年 4 月 15 日
Is the .csv file you are trying to open in your current matlab directory?
per isakson
2017 年 4 月 15 日
Try to use the fully qualified file name; something like
filename = 'c:\folder\of\the\file\dataset.csv';
Ahmad Aseeri
2017 年 4 月 15 日
Star Strider
2017 年 4 月 15 日
You need to look at the file in a text editor to see what it contains. Using textscan with the 'HeaderLines' name-value pair seems an attractive option.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Text Files についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!