read multiple text files to one file

  • Follow


Hello,

I am trying to read multiple text files with different names and write them to a single file. I have  several  n x 3 text files (n varies across files), and would like to read all these files and combine their columns into one m x 3 text file (m is the number of data points from all the files).

Also, how can I perform a paired t-test on specific columns of text files situated in different directories ?

Thanks !
0
Reply Brian 4/13/2010 1:42:03 AM

On Apr 13, 1:42=A0pm, "Brian " <brianb...@gmail.com> wrote:
> Hello,
>
> I am trying to read multiple text files with different names and write th=
em to a single file. I have =A0several =A0n x 3 text files (n varies across=
 files), and would like to read all these files and combine their columns i=
nto one m x 3 text file (m is the number of data points from all the files)=
..
>
> Also, how can I perform a paired t-test on specific columns of text files=
 situated in different directories ?
>
> Thanks !

So, what have you done so far in respect of reading these files?
0
Reply TideMan 4/13/2010 2:27:57 AM


For the reading & combining of the text files part, you can use
fgetl().
0
Reply ImageAnalyst 4/13/2010 2:34:08 AM

TideMan <mulgor@gmail.com> wrote in message <ea4c60bb-0ebe-45db-ad01-978e4cc47644@x3g2000yqd.googlegroups.com>...
> On Apr 13, 1:42 pm, "Brian " <brianb...@gmail.com> wrote:
> > Hello,
> >
> > I am trying to read multiple text files with different names and write them to a single file. I have  several  n x 3 text files (n varies across files), and would like to read all these files and combine their columns into one m x 3 text file (m is the number of data points from all the files).
> >
> > Also, how can I perform a paired t-test on specific columns of text files situated in different directories ?
> >
> > Thanks !
> 
> So, what have you done so far in respect of reading these files?

This is what I have so far, and looking for the most efficient way to write the data from
all these files to a single file:

files_int = dir('*.txt');
for k = 1:length(files_int)
  filename = files_int(k).name;
  output1 = read(filename);
end
0
Reply Brian 4/13/2010 10:34:23 AM

Come on Brian, you can do better than that.  Seriously, how is read()
going to write a file????  And where is any kind of a write
statement????  This is all you could accomplish on your own so far?
Like I said before you can use fgetl() to fetch lines from the files,
then use fprintf() to write those lines out to a single output file.
You'll also need fopen and fclose of course.  I believe the help has
examples for all these functions.
0
Reply ImageAnalyst 4/13/2010 10:44:23 AM

4 Replies
757 Views

(page loaded in 0.067 seconds)

Similiar Articles:













7/21/2012 11:14:10 PM


Reply: