Unable to open file 'Diabetes.csv'.

2 views (last 30 days)
Madiha Rehman
Madiha Rehman on 18 Jan 2022
Edited: Adam Danz on 18 Jan 2022
I'm new to matlab I'm having trouble with this one. Where should I put my excel file so MATLAB can read it?
Code:
%Read data
clc
clear all
close all
data=readtable ('Diabetes.csv');
Error:
Error using readtable (line 143)
Unable to open file 'Diabetes.csv'.
  1 Comment
Star Strider
Star Strider on 18 Jan 2022
Be sure it’s on the MATLAB search path somewhere so that MATLAB can find it.
For help on that see What Is the MATLAB Search Path?.

Sign in to comment.

Answers (1)

Adam Danz
Adam Danz on 18 Jan 2022
Edited: Adam Danz on 18 Jan 2022
To add to @Star Strider's advice, you can put the file anywhere you want as long as it's folder is on the Matlab path. For example, if the file is in C:\Users\name\Documents\Matlab\data then add the path using
addpath('C:\Users\name\Documents\Matlab\data')
Now Matlab will be able to access the file.
Alternatively, you can specify the full path to the file so Matlab knows where it's at even if it's not on the Matlab path,
filepath = 'C:\Users\name\Documents\Matlab\data';
filename = 'Diabetes.csv';
data = readtable(fullfile(filepath, filename));

Products


Release

R2016a

Community Treasure Hunt

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

Start Hunting!