Read Data from .CSV File
조회 수: 3 (최근 30일)
이전 댓글 표시
Hi there,
I am interested to read .csv file into MATLAB but got stuck after several trails. I'm new to MATLAB computation and hope to learn from you guys.
Allow me to explain about the data: The data in the .csv file is separated by comma and each column namely: FileName, Position 1 to 102. I want to be able to skip the first few header lines, then read FileName and its corresponding flow value which is below the 'Position' column. Later on I will do calculation for this 102 number of Flow value and want to output each results associated with the FileName.
Below is the data in .csv file:
---------------------------------------------------------------
New flow data every 10 msec (except APV @ 20 msec)
PS518_10p
Velocities are cm/sec
Spectral bin values
FileName 1 2 3 4 5 .... 102
ASDASD.1.csv 25 -32 -31 -31 -31
SFDFAA.2.csv 25 384 528 222 384
REABZX.3.csv 25 -32 -31 -31 -31
ASDGFA.4.csv 25 222 287 528 287
.
.
.
.
N FileName
Thanks ~Kent
댓글 수: 0
답변 (1개)
Nirmal
2012년 7월 5일
fid = fopen(filename);
M=textscan(fid,'%s','collectoutput',1,'headerlines',0);
fclose(fid);
X=M{1,1};
X will be a array consisting of each line as a row, you will need to parse each row to separate the column.
Hope it helps.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Import and Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!