r - Read special CSV-Data with a loop -


i have little problem , i'm sure guys can me! have file folder in directionary folder consists of on 2000 .csv files.it's called "all data". want read them in r , save them in vectors. know has been asked here before ... i've got:

setwd("c:/users/flo chi/documents/all data") ldf <- list() csvliste <- dir(pattern="*.csv") for(i in 1:length(csvliste)){ldf[[i]] <- read.csv(csvliste[i])} 

csv data

my problem csv data itself! can see in picture e.g. "3327" has comma on both sides. if transfer excel file numbers want (3327, etc.) in column b then. want numbers vector in ldf[[i]]! know how works?

thanks lot answers!

there couple approaches take, if assume possible data forms a) there 1 column of numeric data, or b) if there 2 columns, first column missing.

the example below uses second column anytime finds data frame missing values in first column. wouldn't hard adjust take second column whenever there 2 columns (regardless of in first column)

setwd("c:/users/flo chi/documents/all data") ldf <- lapply(dir(pattern = "*.csv"),         function(i){             df <- read.csv(i)             if (all(is.na(df[, 1]))) df <- df[, 2, drop=false]             df         }) 

Comments