I dont understand this error in line 653 and the end goal is to make a graph

Hi Guys hopefully some of you guys can help. im pretty new to Matlab 2020a and do not have much experience.
i have entered the following code into my live script : (i have attached and shorten verision of the Sep_Consibio Cloud Datalog.csv in this question)
%% Raw data plot for Septemper
% Data import
tic
opts = delimitedTextImportOptions("NumVariables", 4);
% Specify range and delimiter
opts.DataLines = [1, Inf];
opts.Delimiter = ",";
% Specify column names and types
opts.VariableNames = ["Timestamp", "Date", "H2SIn", "H2SOut"];
opts.VariableTypes = ["double", "datetime", "double", "double"];
% Specify file level properties
opts.ExtraColumnsRule = "ignore";
opts.EmptyLineRule = "read";
% Specify variable properties
opts = setvaropts(opts, "Date", "InputFormat", "dd/MM-yy HH:mm:ss");
% Import online measurement data from Consibio
ConsibioSepdatalog = readtable("Users\amil\Documents\MATLAB\Rawdata2022\Sep_Consibio Cloud Datalog.csv", opts);
ConsibioSepdatalogTrimNew = ConsibioSepdatalog(:,:);
toc
and get the following Error using matlab.io.ImportOptions/readtable (line 653)
Unable to find or open 'Users\amil\Documents\MATLAB\Rawdata2022\Sep_Consibio Cloud Datalog.csv'. Check the path and filename or file permissions. --> however the document is in the same folder as the live script --> i how give my file permission? I'm an apple user and have a MacBook Air (13-inch, 2017) 8 GB 1600 MHz DDR3, icore 5.
the goal is to use the Rawdata in a plot where the x-axis is time [dd.mm.hh.mm:ss] and y- axis is for the concenctration in and out of H2S [ppm]
  • if you have any suggestion for this part of the code please comment :)

 Accepted Answer

Since the file is in the same folder as the m-file, you can do
fullFileName = fullfile(pwd, 'Sep_Consibio Cloud Datalog.csv');
if ~isfile(fullFileName)
errorMessage = sprintf('File not found:\n"%s"\nCheck the spelling.')
uiwait(errordlg(errorMessage));
return;
end
% If you get here, the file exists.
fprintf('Processing "%s".', fullFileName)
ConsibioSepdatalog = readtable(fullFileName, opts);

4 Comments

thank you for your answer but what function/command does have? does it give a info about when the file is imported?
fprintf('Processing "%s".', fullFileName)
i get the following information elasped time is 4 seconds and it says Processing "Users\amil\Documents\MATLAB\Rawdata2022\Sep_Consibio Cloud Datalog.csv"
It just tells you what file is being processed at that point in time. If you don't want that information printed to the command window, you can delete that line.
Ok thx you - No alert was given of the file not exist. That mean with your code i have imported the file i guess.
Yes. So it must have found it. Since it did, it would have printed it out to the command window. If you want a popup message you can do
fullFileName = fullfile(pwd, 'Sep_Consibio Cloud Datalog.csv');
if ~isfile(fullFileName)
errorMessage = sprintf('File not found:\n"%s"\nCheck the spelling.')
uiwait(errordlg(errorMessage));
return;
end
% If you get here, the file exists.
message = sprintf('Success! Found the file!\nNow processing "%s".', fullFileName);
fprintf('%s\n', message); % Print to command window.
uiwait(helpdlg(message)); % Pop up a dialog box with the same info.
ConsibioSepdatalog = readtable(fullFileName, opts);

Sign in to comment.

More Answers (2)

Get rid of the gaps between Consibio and Cloud, and between Cloud and Datalog (In the file name and when calling it).

2 Comments

thanks for you answer unfortunatly it didnt work
What about my answer below? Did you try that? It will alert you if the file does not exist.

Sign in to comment.

ConsibioSepdatalog = readtable("C:\Users\amil\Documents\MATLAB\Rawdata2022\Sep_Consibio Cloud Datalog.csv", opts);
You omitted the drive and leading \ . When you omit the leading \ then you are asking to look in a directory named Users inside your current folder

Categories

Find more on Parallel Computing in Help Center and File Exchange

Products

Release

R2020a

Asked:

on 12 Apr 2023

Commented:

on 13 Apr 2023

Community Treasure Hunt

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

Start Hunting!