Why is my CSV reader not working?
2 views (last 30 days)
Show older comments
clc; clear;
% Path to Data Files.
path = "C:/Users/Desktop/File Names";
% Number of F & G.
No_F = 32; No_G = 32;
% Defines the first ten file names by adding the '0' infront of the file number.
for i = 0:9;
fname(i + 1) = strcat("i_0", string(i), ".CSV");
fnamelabel(i + 1) = strcat("i\_0", string(i));
end
% Defines the rest of the file names using the given file number.
for i = 10:No_F-1;
fname(i + 1) = strcat("i_", string(i), ".CSV");
fnamelabel(i + 1) = strcat("i\_", string(i));
end
% Reads the time column from the first measurement.
% time = csvread(strcat(path,fname(1)),1,0,[1,0,10000,0]);
time = csvread('i_00.CSV', 1, 0, [1, 0, 10000, 0]);
for i = 1:No_F;
temp = strcat(path, fname(i));
data(:,:,i) = csvread(temp, 1, 1, [1, 1, 10000, No_F]); %%%% Error using csvread, File not found.
end
The line that doesn't work is:
data(:,:,i) = csvread(temp, 1, 1, [1, 1, 10000, No_F]);
0 Comments
Answers (1)
Image Analyst
on 18 Feb 2019
It's probably not a csv file. Try importdata() instead. Attach one of the CSV files that it fails on if importdata() does not work.
0 Comments
See Also
Categories
Find more on Data Import and Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!