MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

RE: reading all the files in one directory


Hi Sofia, 

> Could anyone please tell me how can a read all the files in 
> one directory?
> I have to read around 60 files with odd names.

It's straightforward ....  

Change to the directory; get a list of the file names; read them,
prefereably using Import[]; continue.

For example, below I read all the txt files into a list.  The i'th element
of the list contains data from the i'th file. 

	SetDirectory["c:/Tmpfiles"];
	ifile = FileNames["*.txt"]
	idata = Import[#, "LIST"] & /@ ifile;

If it is sensible to do so (it depends on the structure of the individual
lists), you can plot the data individually using
	
	ListPlot[#]& /@ idata;

Or all together using

	MultipleListPlot[idata];

Regards,

Dave.


  • Prev by Date: Re: reading all the files in one directory
  • Next by Date: Re: reading all the files in one directory
  • Previous by thread: Re: reading all the files in one directory
  • Next by thread: Re: reading all the files in one directory