1

I have directory in PC where are all my *.log files saved. The goal is to write code, where I can specify for which day I want to see merged data. Data from one day is divided into e.g. 10 files.

I´ve tried following:

setwd("D:/Assembly lags/SK190400 ghp tracer/")
file_list<-list.files(pattern="LOG_SK190400_2018.03.13_*")

Result is:

[1] "LOG_SK190400_2018.03.13_03-40-56-704.log" "LOG_SK190400_2018.03.13_06-36-35-019.log" "LOG_SK190400_2018.03.13_09-17-35-899.log"
[4] "LOG_SK190400_2018.03.13_12-33-43-891.log" "LOG_SK190400_2018.03.13_15-31-09-628.log" "LOG_SK190400_2018.03.13_18-38-33-424.log"
[7] "LOG_SK190400_2018.03.13_22-11-44-855.log"    

Data in files looks like:

     Time         Type  Station            Log_time
1   08:40:01.7462 UNIT_RESULT SK190400      272
2   08:40:11.6187 UNIT_CHECKI SK190400      257
3   08:40:18.1471 UNIT_RESULT SK190400      306
4   08:40:27.9737 UNIT_CHECKI SK190400      224

All files has same design. I have tried functions like:

lapply

rbind

list

But nothing has returned any useful result

makoLP
  • 23
  • 4
  • 3
    Have you seen this? https://stackoverflow.com/questions/5758084/loop-in-r-to-read-many-files – Tim Biegeleisen Jun 06 '18 at 06:51
  • I have tried function lapply but as long as I do not have *.csv files I can not use function read.csv. Therefore function lapply returns error. – makoLP Jun 06 '18 at 07:26

1 Answers1

0

Try fread from data.table

library (data.table)
setwd("D:/Assembly lags/SK190400 ghp tracer/")
file_list<-list.files(pattern="LOG_SK190400_2018.03.13_*")

log_2018.03.13<-lapply(file_list, fread)

You could easily use a loop for dates or another lapply

SatZ
  • 430
  • 5
  • 14