Unable to read data with .clv extension

1 回表示 (過去 30 日間)
Mar
Mar 2018 年 7 月 26 日
コメント済み: KALYAN ACHARJYA 2018 年 7 月 30 日
Hi,
I am trying to import multiple csv files into Matlab (.csv extension) but I am keep getting an empty structure.
Following online suggestions I used the following line of code:
d = dir('/Users/file_*.clv');
images = arrayfun(@(f) csvread(f.name), dircontent, 'UniformOutput', false);
image = cat(3, images{:});
For some reason seems like Matlab doesn't read the data. I got the following when I checked the size(image). I was expecting a 3D array instead.
ans =
0 0
Below the code I used with the .csv extension:
d = dir('/Users/file_*.csv');
images = arrayfun(@(f) csvread(f.name), dircontent, 'UniformOutput', false);
image = cat(3, images{:});
I got the following error:
>> mult_csv
Error using csvread (line 35)
File not found.
Error in mult_csv>@(f)csvread(f.name)
Error in mult_csv (line 8)
images = arrayfun(@(f) csvread(f.name), dircontent, 'UniformOutput', false);
Any ideas?
P.S. I attached an example of my csv files.
  5 件のコメント
Mar
Mar 2018 年 7 月 26 日
I've edited my post to make things more clear. I also attached a file as requested.
Guillaume
Guillaume 2018 年 7 月 26 日
Oh, so this is just a continuation of import-multiple-csv-files-in-matlab.
For some reason, I missed that you commented there (There was a problem yesterday where the activity feed stopped updating for a few hours). I've now updated my answer.

サインインしてコメントする。

回答 (1 件)

KALYAN ACHARJYA
KALYAN ACHARJYA 2018 年 7 月 26 日
編集済み: KALYAN ACHARJYA 2018 年 7 月 30 日
% Please save all files name in symmetrically before doing the operation
%keep in all one folder, so you avoid the confusion with others files
% names for example f1,f2,f3...
%Save the folder of files in the current directory
path_directory='folder_name_here';
% Pls note the format of files,change it as required
original_files=dir([path_directory '/*.file_extention_format']);
for k=1:length(original_files)
filename=[path_directory '/' original_files(k).csv];
file(k)=csvread (filename);
% Next do your operation and finding
end
  3 件のコメント
Guillaume
Guillaume 2018 年 7 月 26 日
Note that if the files are csv files, xlsread is the slowest possible way to read these files. csvread would be much faster.
KALYAN ACHARJYA
KALYAN ACHARJYA 2018 年 7 月 30 日
Thanks @Guillaume

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by