循环遍历matlab中文件夹中的文件 [英] Loop through files in a folder in matlab

查看:55
本文介绍了循环遍历matlab中文件夹中的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一组日志文件需要在 matlab 中解析和查看.

I have a set of days of log files that I need to parse and look at in matlab.

日志文件如下所示:

LOG_20120509_120002_002.csv
(year)(month)(day)_(hour)(minute)(second)_(log part number)

日志每小时递增一次,但有时秒数会减少一到两秒(每小时),这意味着我需要忽略他们说要做什么 loadcsv.

The logs increment hourly, but sometimes the seconds are one or two seconds off (per hour) which means i need to ignore what they say to do loadcsv.

我还有另一个文件:

LOG_DATA_20120509_120002.csv

包含整个小时的数据(不同的数据).

which contains data for the whole hour (different data).

总体目标是:

 loop through each day 
     loop through each hour
         read in LOG_DATA for whole hour
         loop through each segment
             read in LOG for each segment
                 compile a table of all the data

我想问题是,如果一天中的分钟不同,我该如何忽略它们?我怀疑它将通过循环遍历文件夹中的所有文件,在这种情况下我该怎么做?

I guess the question is then, how do i ignore the minutes of the day if they are different? I suspect it will be by looping through all the files in the folder, in which case how do i do that?

推荐答案

遍历文件夹中的所有文件相对容易:

Looping through all the files in the folder is relatively easy:

files = dir('*.csv');
for file = files'
    csv = load(file.name);
    % Do some stuff
end

这篇关于循环遍历matlab中文件夹中的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆