How do I import first two columns using csvread over a specific range without knowing the total number of rows?

14 views (last 30 days)
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?

Accepted Answer

Image Analyst
Image Analyst on 28 Jan 2013
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.

More Answers (0)

Categories

Find more on Data Import and Analysis in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

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

Start Hunting!