Hi Jim

thanks for the help. I think I understand all the steps you suggested. I
tried an example with your code but there is something not working I think.
See below.

all.filenames<-list.files(**path="pathtofile", full.names=TRUE) *#this step
works*
old.filenames<-read.table("**old.filenames.tab") *#this step works*
filenames<-all.filenames[!(**all.filenames %in% old.filenames)]* ## I think
the problem is here because all.filenames = filenames (also checked with
str()), so I import all the files (old and new files added to my folder)
each time I run the code.*
write.table(all.filenames,**file="old.filenames.tab",row.**names=FALSE) *#this
step works*

Any suggestion?
thanks again
martin


On Sun, Apr 21, 2013 at 6:30 PM, Jim Lemon <j...@bitwrit.com.au> wrote:

> On 04/22/2013 05:36 AM, Martin Lavoie wrote:
>
>> Hi All
>>
>> I want to import several .dat files every day of the week from the same
>> folder.
>>
>> Let say, on day 1, I have about 100 files in the folder.
>>
>> By using this code, everything works perfectly (maybe there is a more
>> efficient way to do it):
>>
>> filenames<-list.files(path="**pathtofile", full.names=TRUE)
>> library(plyr)
>> import.list<- llply(filenames, read.table, header=TRUE, sep="",
>> na.strings="NA", dec=".", strip.white=TRUE)
>> #
>> #MERGE and RESHAPE some of the files have different columns
>> library(reshape)
>> data3<- merge_recurse(import.list)
>> #
>> At the end of each day I will export the file as a cvs file in a different
>> folder.
>>
>> My question is how can I import on day 2 (day3, day4, etc) the new files
>> in
>> the folder but without importing the files already imported from the
>> previous days.
>>
>>  Hi Martin,
> Here is one method:
>
> # first set up a dummy file for the first run to avoid an error
> system("echo xxx > old.filenames.tab")
> # obviously don't do this again
> all.filenames<-list.files(**path="pathtofile", full.names=TRUE)
> old.filenames<-read.table("**old.filenames.tab")
> filenames<-all.filenames[!(**all.filenames %in% old.filenames)]
> write.table(all.filenames,**file="old.filenames.tab",row.**names=FALSE)
>
> library(plyr)
> import.list<- llply(filenames, read.table, header=TRUE, sep="",
> na.strings="NA", dec=".", strip.white=TRUE)
> ...
>
> Jim
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to