1. Produce vectors of character strings with the names of the *.xls
files and of the target data.frames you want to create. For example,
the following will "station60", "station61", ..., "station800":
DFname <- paste("station", 60:800, sep="")
You can then delete the ones that don't exist. Then convert this to
file names as follows:
Fname <- paste(DFname, ".xls", sep="")
Alternatively, copy the results of a "dir" into Excel, strip away
what you don't want, save the names of the files you want to import, and
delete the ".xls" with something like the following:
Period <- regexpr("\\.", Fnames)
DFnames <- substring(Fnames, 1, Period-1)
2. Use the GUI File -> "Import Data" -> "From File" dialog process
for the first of the files.
3. Window -> History -> Display -> OK. Then copy the
"guiImportData" command into a script file in a loop, replacing the
FileName argument with Fname[i] and the TargetDataFrame arguments with
DFname[i]. Set i <- 1, and try it until you get it to work. Then try i
<- 1+i, and try it again. After you think you have all the options like
you want them, you can get the rest in a loop.
spencer graves
Sarah Henderson wrote:
Hello to all and, once again, my apologies for what is probably a very
novice question.
I have a folder full of 300 .xls files that I need to import into
S-Plus. All files have the same name structure (eg. 'station*.xls'
where the * is some number between 60 and 800). Is there any way in
which the import.data function can be written for a batch import these
files? Or can I write my own function that calls import.data and passes
a file name as the parameter? I have been experimenting (quite blindly)
with possible alternatives, but nothing has worked out so far. Any
suggestions will be greatly appreciated.
Once again, I'm working with S-Plus 6.2 (student edition) in a Windows
XP platform.
Many thanks,
Sarah
--------------------------------------------------------------------
This message was distributed by s-news@lists.biostat.wustl.edu. To
unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
the BODY of the message: unsubscribe s-news
--
Spencer Graves, PhD
Senior Development Engineer
PDF Solutions, Inc.
333 West San Carlos Street Suite 700
San Jose, CA 95110, USA
spencer.graves@pdf.com
www.pdf.com <http://www.pdf.com>
Tel: 408-938-4420
Fax: 408-280-7915
|