Thread Subject: importing multiple data files

Subject: importing multiple data files

From: Alix

Date: 8 May, 2009 20:44:02

Message: 1 of 2

I am trying to write a script that loads a .txt data file from a folder (say 1.txt), does some analysis on it, exports the variables I need to a file (say 1_a.txt), and then takes the next data file in the folder and does the same thing (although I want the next imported file, 2.txt, to have its variables saved as 2_a.txt) until all of the files have been analyzed without me having to load/save the the file each time. Is there an easy way to do this? I am just having problems with the importing/exporting part.

Alt the top of these .txt files is a brief description of how the data was taken. I was also wondering if there was a way to keep this description when I save the variables.

Subject: importing multiple data files

From: John

Date: 13 May, 2009 16:21:02

Message: 2 of 2

In your script,
1) To read from data files in your folder ,use the dir command like this to get all filenames
  f=dir('*.txt'); % when running this script in the same directory as the files or f= dir(<path to folder/*.txt');

2) f.name is a cell array of strings containing all the txt files.

3) Run a loop to access all files from f.name , do the analysis and save the results.

4) Cant your read the description string from the top of the file and write it to the results file use fprintf ?



"Alix " <preston@phys.ufl.edu> wrote in message <gu25ii$5hn$1@fred.mathworks.com>...
> I am trying to write a script that loads a .txt data file from a folder (say 1.txt), does some analysis on it, exports the variables I need to a file (say 1_a.txt), and then takes the next data file in the folder and does the same thing (although I want the next imported file, 2.txt, to have its variables saved as 2_a.txt) until all of the files have been analyzed without me having to load/save the the file each time. Is there an easy way to do this? I am just having problems with the importing/exporting part.
>
> Alt the top of these .txt files is a brief description of how the data was taken. I was also wondering if there was a way to keep this description when I save the variables.

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
loading data Alix 8 May, 2009 16:44:03
saving data Alix 8 May, 2009 16:44:03
rssFeed for this Thread

Contact us at files@mathworks.com