0

I have a logfile this type to process in R :

2015-11-23 11:51:02,082  INFO      FrameworkApplication - ****** Start entimICE Application Command Line Parameters ******
2015-11-23 11:51:02,082  INFO      FrameworkApplication - ****** Config-File: E:/Program Files (x86)/conf/storages.dsconfig
2015-11-23 11:51:02,082  INFO      FrameworkApplication - ****** Datasource: datasource
2015-11-23 11:51:02,082  INFO      FrameworkApplication - ****** Application: App
2015-11-23 11:51:02,082  INFO      FrameworkApplication - ****** Ignore : false
2015-11-23 11:51:02,082  INFO      FrameworkApplication - ****** Plugin: com.plug
2015-11-23 11:51:02,082  INFO      FrameworkApplication - ****** Logging: E:/Program Files (x86)/conf/log4j.properties
2015-11-23 11:51:02,082  INFO      FrameworkApplication - ****** End Application Command Line Parameters ******
2015-11-23 11:51:02,129  INFO               BaseRuntime - Runtime created in mode: RichClient

I tried to put it in a dataframe with read table, but it puts me each word in a column and i would like to have a data frame with 5 columns:

date        time           type  element              text
2015-11-23  11:25::02,082  info  FrameworkAplication  - ****** Start entimICE Application Command Line Parameters ******

The probleme is my field separator is a space as well as my word separator that i don't want in diffrent fields

Is it possible via read.table, or scan, or should i do my own function ?

Thanks,

m33kael
  • 33
  • 4
  • 1
    Yes but the last term has a variable length which causes a problem too then, I didn't see any argument that could help in this case – m33kael Feb 24 '16 at 10:18

1 Answers1

0

@ma33kael did you even try the solution in the duplicate? Because it works as expected

library(readr)
a <- read_fwf(text, fwf_widths(c(10,13,6,1)))

gives you:

          X1           X2   X3                                                                                       X4
1 2015-11-23 11:51:02,082 INFO  FrameworkApplication - ****** Start entimICE Application Command Line Parameters ******
2 2015-11-23 11:51:02,082 INFO FrameworkApplication - ****** Config-File: E:/Program Files (x86)/conf/storages.dsconfig
3 2015-11-23 11:51:02,082 INFO                                     FrameworkApplication - ****** Datasource: datasource
4 2015-11-23 11:51:02,082 INFO                                           FrameworkApplication - ****** Application: App
5 2015-11-23 11:51:02,082 INFO                                             FrameworkApplication - ****** Ignore : false
6 2015-11-23 11:51:02,082 INFO                                           FrameworkApplication - ****** Plugin: com.plug
7 2015-11-23 11:51:02,082 INFO      FrameworkApplication - ****** Logging: E:/Program Files (x86)/conf/log4j.properties
8 2015-11-23 11:51:02,082 INFO             FrameworkApplication - ****** End Application Command Line Parameters ******
9 2015-11-23 11:51:02,129 INFO                                        BaseRuntime - Runtime created in mode: RichClient

data:

text <- "2015-11-23 11:51:02,082  INFO      FrameworkApplication - ****** Start entimICE Application Command Line Parameters ******
2015-11-23 11:51:02,082  INFO      FrameworkApplication - ****** Config-File: E:/Program Files (x86)/conf/storages.dsconfig
2015-11-23 11:51:02,082  INFO      FrameworkApplication - ****** Datasource: datasource
2015-11-23 11:51:02,082  INFO      FrameworkApplication - ****** Application: App
2015-11-23 11:51:02,082  INFO      FrameworkApplication - ****** Ignore : false
2015-11-23 11:51:02,082  INFO      FrameworkApplication - ****** Plugin: com.plug
2015-11-23 11:51:02,082  INFO      FrameworkApplication - ****** Logging: E:/Program Files (x86)/conf/log4j.properties
2015-11-23 11:51:02,082  INFO      FrameworkApplication - ****** End Application Command Line Parameters ******
2015-11-23 11:51:02,129  INFO               BaseRuntime - Runtime created in mode: RichClient"
Rentrop
  • 20,979
  • 10
  • 72
  • 100