Reading specific cell from several csvs
조회 수: 3 (최근 30일)
이전 댓글 표시
Hi,
Let me preface this question by saying I've just started using MATLAB recently and my familiarity with it is pretty poor.
I have just output 120 csv files with co-ordinate data in them. The first 6 rows of each csv contain redundant text regarding the output (ie date of processing, file location, sampling rate etc). Thereafter, the 7th row is filled with variable names and rows 8-13 numerical values corresponding to the relevant columnar variable. I only need one number in this entire data set, which is always at (row 13, column 3). I could obviously open every csv and manually record this value in a summary spreadsheet. I could also slit my wrists...
So my question is, is it possible to write a code that will read the 120 csv files and output the value of cell C13 into a new spreadsheet (writing each value on a new line therein)? And if so, when I'm running this code in MATLAB, will I need to run the code 120 times and select a new csv each time, or can you select all 120 csvs at once so that the code just runs a single time, over everything? And finally, can anyone direct me to the most useful source to write this code?
Many thanks Don
댓글 수: 0
채택된 답변
Daniel Shub
2011년 10월 19일
doc dlmread
I cannot tell what row and column the number you need is. But assuming C13 means column 1 and row 13.
filename = 'myfile.csv';
x = dlmread(filename, ',', 12, 0);
Getting the filenames into variable filename depends on your naming convention and directory structure. It is address pretty well in the FAQ
댓글 수: 0
추가 답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Environment and Settings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!