Possible Duplicate:
Read multiple CSV files into separate data frames
I need to read many csv files into dataframes from one folder. The csv file names are of the form fxpair-yyyy-mm.csv (e.g. AUDJPY-2009-05.csv). I want to read all csv files in and create dataframes of the form fxpair.yyyy.mm
I am having trouble creating the dataframe names in the loop for assignment from the read.csv statements
filenames <- list.files(path=getwd())
numfiles <- length(filenames)
#fx.data.frames to hold names that will be assigned to csv files in csv.read
fx.data.frames <- gsub(pattern="-",x=filenames,replacement=".")
fx.data.frames <- gsub(pattern=".csv",x=fx.data.frames,replacement="")
i <-1
for (i in c(1:numfiles)){
filenames[i] <- paste(".\\",filenames[i],sep="")
fx.data.frames[i] <- read.csv(filenames[i], header=FALSE)
}
The csv.read seems to work fine but I am not able to create the dataframe objects in the way I intend. I just want some way to name the dataframes read in the fxpair.yyyy.mm format based on the file name.
Am I missing something obvius? THANK YOU FOR ANY HELP!!