MATLAB: How to import first two columns using csvread over a specific range without knowing the total number of rows

csvreadMATLAB

I'm trying to use csvread for a specific range of the file, but the number of rows in the csv file changes for every file. Here's some code to help you understand what I want to do: csvread('03.csv',0,0,[0,0,:,1])
The goal is to read the first 2 columns in their entirety without knowing the total number of rows. The colon does not work, neither does leaving it blank (i.e., [0,0,,1]). Is there another way to tell it to read until there is no more data?

Best Answer

Just read the whole thing and extract the first 2 columns
M = csvread('03.csv'); % Read entire file.
first2Columns = M(:,1:2); % Extract out the first two columns.
Related Question