Reading specific cell from several csvs
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuesta aceptada
Daniel Shub
el 19 de Oct. de 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 comentarios
Más respuestas (1)
Ver también
Categorías
Más información sobre Environment and Settings en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!