필터 지우기
필터 지우기

How do I get a range of data from csv with unequal columns?

조회 수: 4 (최근 30일)
Iain Hunter
Iain Hunter 2019년 2월 22일
답변: Walter Roberson 2019년 2월 22일
I want to read in a section of this data.csv. Everything works fine with the xlsx version of the file.
A = xlsread(filename,1, 'I9..N30008');
The trouble is I would rather pull it in as a csv so that I don't have to save all my csv files as xlsx. I think the difficulty arises since there are not equal column numbers on every row.

답변 (1개)

Walter Roberson
Walter Roberson 2019년 2월 22일
T = readtable('data.csv', 'HeaderLines', 8, 'ReadVariableNames', false, 'Delimiter', ',');
If you need to convert the second column into dates, then
dates = datetime(T{:,2}, 'InputFormat', 'MM/dd/yyyy hh:mm:ss.SSS a');
and the pure numeric part (ignoring the first column that gives row numbers) would be
num = T{:,3:14};
The events are at T{:,15} and T{:,16}

카테고리

Help CenterFile Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by