So I want to import and edit a huge amount of data. I have a file with multiple data sets from time series that are chronologically ordered. Now I want to open them and edit to have a final dataset where the files are edited and ordered.
The code looks like this but it is taking some time to load the data:
setwd <-("C:/Users/D60378/Desktop/DATA")
path_data <- 'test'
files_data <- list.files(path_data)
length(files_data)
for (i in 1:length(files_data)){
# use intermediary path if nested dir
tempPath <- file.path(getwd(), path_data, files_data[i])
# name of the dataser
name <- gsub('-', '_', substr(files_data[i], start = 0, stop = (nchar(files_data[i])-4)))
print(name)
df <- read.csv(tempPath, skip=5, header=FALSE, sep = ';', dec = ',') #sheet 1 is the
# column names
df_names <- read.csv(tempPath, skip=4, nrows=1, header=FALSE, sep = ';', dec=',')
dfnames_test_MS7 <- c()
for (i in 1:length(df_names)){
print(as.character(df_names[[i]]))
dfnames_test_MS7[i] <- as.character(df_names[[i]])
}
dfnames_test_MS7[1] <- "DateTime"
for (i in 1:length(dfnames_test_MS7)){
dfnames_test_MS7[i] <- gsub(' ', '_', dfnames_test_MS7[i])
}
dfnames_test_MS7
names(df) <- dfnames_test_MS7
assign(name, df)
}