Thread Subject:
import data from files

Subject: import data from files

From: mee gestaf

Date: 7 Nov, 2011 15:32:13

Message: 1 of 3

Please someone give me a hint with this one.
I want to make a application that automatically reads data from .mat files saved in a folder.
In folder I have many files that look like this :

ChPow---18-10---1-26.mat
 ZSpan---18-10---1-9.mat
ChPow---18-10---1-35.mat
ZSpan---18-10---10-1.mat
ChPow---18-10---1-43.mat
 ZSpan---18-10---10-19.mat
ChPow---18-10---1-53.mat
 ZSpan---18-10---10-29.mat
ChPow---18-10---10-10.mat
ZSpan---18-10---10-37.mat
ChPow---18-10---10-2.mat
 ZSpan---18-10---10-45.mat

Where "18-10" is the date when they were created, and the other one ex. "1-26" is the hour and minute. I want to process only the .mat files that are between two given start and stop time, in the order that they were created. I'm blocked because I don't know how to query those in the name of the files. If I do a "dir" command in matlab it will give me a structural variable that has information about every file when it was created in a string format, and I don't know if matlab can calculate time comparison. I was thinking of making a matrix with all the files that meet the criteria and then invoke them to read the data from them.
Please help...

Subject: import data from files

From: ade77

Date: 7 Nov, 2011 16:27:13

Message: 2 of 3

"mee gestaf" wrote in message <j98tlt$4rm$1@newscl01ah.mathworks.com>...
> Please someone give me a hint with this one.
> I want to make a application that automatically reads data from .mat files saved in a folder.
> In folder I have many files that look like this :
>
> ChPow---18-10---1-26.mat
> ZSpan---18-10---1-9.mat
> ChPow---18-10---1-35.mat
> ZSpan---18-10---10-1.mat
> ChPow---18-10---1-43.mat
> ZSpan---18-10---10-19.mat
> ChPow---18-10---1-53.mat
> ZSpan---18-10---10-29.mat
> ChPow---18-10---10-10.mat
> ZSpan---18-10---10-37.mat
> ChPow---18-10---10-2.mat
> ZSpan---18-10---10-45.mat
>
> Where "18-10" is the date when they were created, and the other one ex. "1-26" is the hour and minute. I want to process only the .mat files that are between two given start and stop time, in the order that they were created. I'm blocked because I don't know how to query those in the name of the files. If I do a "dir" command in matlab it will give me a structural variable that has information about every file when it was created in a string format, and I don't know if matlab can calculate time comparison. I was thinking of making a matrix with all the files that meet the criteria and then invoke them to read the data from them.
> Please help...


use regexp to decipher which filenames u want.
extract all the filenames using "dir" and "name" field

for i = 1:number of files
if (regexp(decipher file name) is what I want)
process the file
end
end

if the filenames have consistent names, u can also use strcmp or strncmp instead of regexp

Subject: import data from files

From: mee gestaf

Date: 7 Nov, 2011 19:17:30

Message: 3 of 3

Thanks for the help


"ade77 " <ade100a@gmail.com> wrote in message <j990t1$gci$1@newscl01ah.mathworks.com>...
> "mee gestaf" wrote in message <j98tlt$4rm$1@newscl01ah.mathworks.com>...
> > Please someone give me a hint with this one.
> > I want to make a application that automatically reads data from .mat files saved in a folder.
> > In folder I have many files that look like this :
> >
> > ChPow---18-10---1-26.mat
> > ZSpan---18-10---1-9.mat
> > ChPow---18-10---1-35.mat
> > ZSpan---18-10---10-1.mat
> > ChPow---18-10---1-43.mat
> > ZSpan---18-10---10-19.mat
> > ChPow---18-10---1-53.mat
> > ZSpan---18-10---10-29.mat
> > ChPow---18-10---10-10.mat
> > ZSpan---18-10---10-37.mat
> > ChPow---18-10---10-2.mat
> > ZSpan---18-10---10-45.mat
> >
> > Where "18-10" is the date when they were created, and the other one ex. "1-26" is the hour and minute. I want to process only the .mat files that are between two given start and stop time, in the order that they were created. I'm blocked because I don't know how to query those in the name of the files. If I do a "dir" command in matlab it will give me a structural variable that has information about every file when it was created in a string format, and I don't know if matlab can calculate time comparison. I was thinking of making a matrix with all the files that meet the criteria and then invoke them to read the data from them.
> > Please help...
>
>
> use regexp to decipher which filenames u want.
> extract all the filenames using "dir" and "name" field
>
> for i = 1:number of files
> if (regexp(decipher file name) is what I want)
> process the file
> end
> end
>
> if the filenames have consistent names, u can also use strcmp or strncmp instead of regexp

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
import data mee gestaf 7 Nov, 2011 10:34:17
from files mee gestaf 7 Nov, 2011 10:34:17
query mee gestaf 7 Nov, 2011 10:34:17
rssFeed for this Thread

Contact us