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!