readtable error in Matlab
Show older comments
Hi,
I am reading a table from a csv file using the readtable command, and specifying specic range. However when I run the line, the following error appears. "Error using readtable. Invalid parameter name: Range". Anybody know what is wring? I am running the code on R2015b version of Matlab.
data = readtable('data.csv','Range','A1:C10');
2 Comments
Rik
on 1 Mar 2023
Did you check the documentation in R2015b to confirm this parameter exists and has this name?
Jayden Yeo
on 1 Mar 2023
Accepted Answer
More Answers (1)
Pratheek
on 1 Mar 2023
0 votes
Hi Jayden Yeo,
You are facing this issue since, in R2015b version of MATLAB, comma-delimited text files(.txt, .dat, .csv) allow only limited parameters.
They are - ReadVariableNames, ReadRowNames, TreatAsEmpty, HeaderLines, Format, DateLocale, FileEncoding.
For Spreadsheet files(.xls, .xlsx, .xlsb, .xlsm, .xltm, .xltx, .ods) we can use these parameters- ReadVariableNames, ReadRowNames, TreatAsEmpty, Sheet, Range, Basic.
As you are working with a .csv file you can't use Range parameter
A workaround for you issue can be
T = readtable('myfile.csv');
T_range = T(startRow:endRow, startCol:endCol);
1 Comment
Jayden Yeo
on 2 Mar 2023
Categories
Find more on Large Files and Big Data 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!