Reading specific cell from several csvs
3 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
Daniel Shub
on 19 Oct 2011
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 Comments
More Answers (1)
See Also
Categories
Find more on Environment and Settings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!