CSV file that needs to be run through MATLAB?

New to MATLAB. I have been given data in a CSV file that needs to be run through a given MATLAB code and I do not know where to even start. Can anyone help me?

6 Comments

Duplicate:
"Can anyone help me?"
You can help you, by reading the links that Star Strider gave you. They show how to import data. If you tried them and something did not work then please add comments to that question, showing exactly what you tried.
It does not help to simply ask the same question again and again.
I have looked through the links and they don't make sense to me.
Hi Kristine,
If you are looking to read from a CSV file, I would recommend starting with the "readtable" function in MATLAB. This should be able to read in the data and store it in a MATLAB table so that you can use it.
More information about this function can be found at the link below: https://www.mathworks.com/help/matlab/ref/readtable.html
Hi Steven,
I have tried this but the following error has appeared.
Error in line 3
T = readtable('cardio_test_2, Value');
In the description the file is definitely a Microsoft Excel Comma Separated Values File (.csv).
The file is on a memory pen so I tried using the full path name and this doesn't change the error... What do you think?
Does the file name really have a comma and space in it? And does it really not have a file extension?
I speculate that you are interested in the column named Value in the file cardio_test_2.csv
T = readtable('cardio_test_2.csv');
T.Value
Hi Walter,
This is what I now have currently but MATLAB is ignoring this line and jumping straight to the code
T = readtable('E:\Uni\Final\MATLAB\Assignment 1\cardio_test_2.csv');

Sign in to comment.

 Accepted Answer

Andrew Padilla
Andrew Padilla on 12 Nov 2018
Edited: Andrew Padilla on 12 Nov 2018
Kristine,
Have you tried loading in the data using the csvread() function?
If you have a csv file that is named "Test.csv" you can import it to your workspace using the following:
data = csvread('Test.csv');

13 Comments

Is this for the full file name?
Come back with Error in B00690215_Assignment_1 (line 4)
data = csvread('cardio_test_2');
Error in B00690215_Assignment_1 (line 3)
data = csvread('E:\Uni\Final\MATLAB\Assignment 1\cardio_test_2.csv');
What is the complete error message?
Have you posted an example of the csv file you are dealing with?
Please see attached CSV file. I have moved on to try to use
T = table
T = table ('val1','val13');
Walter, full error is
Error in csvread (line 48)
m=dlmread(filename, ',', r, c);
Error in B00690215_Assignment_1 (line 3)
data = csvread('E:\Uni\Final\MATLAB\Assignment 1\cardio_test_2.csv');
Kristine,
you need to include the property of the file in the csvread() function. In other words, add the .csv.
Try this,
data = csvread('cardio_test_2.csv');
Error in B00690215_Assignment_1 (line 3)
data = csvread('cardio_test_2.csv');
Could you send a screenshot of your data set? I think it has something to do with the actual set of data that you are trying to work with.
A screenshot of the CSV file?
It has a text column. It cannot be used with csvread() or dlmread(). You will need to use readtable() or textscan()
Thanks all! This has helped!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!