我想將日誌事件加載到data.table
,每個日誌由timestamp
標識,並且一些日誌可以包含許多行。將具有特定分隔符的文本導入r
我有以下.txt
文件:
2016-07-19 00:00:01,421 WARNING Exception happened while transfering for command
at java.lang.NumberFormatException
at java.lang.Integer.parseInt
at java.util.concurrent.Task
2016-07-19 00:01:01,525 DEBUG Upload all environments
2016-07-19 00:01:01,720 DEBUG Upload all environments
2016-07-19 00:02:00,520 WARNING Excpetion happened while transfering for command
at java.lang.NumberFormatException
我希望得到以下data.table
:
log
1 2016-07-19 00:00:01,421 WARNING Exception happened while transfering for command at java.lang.NumberFormatException at java.lang.Integer.parseInt at java.util.concurrent.Task
2 2016-07-19 00:01:01,525 DEBUG Upload all environments
3 2016-07-19 00:01:01,720 DEBUG Upload all environments
4 2016-07-19 00:02:00,520 WARNING Excpetion happened while transfering for command at java.lang.NumberFormatException
我想每個日誌事件上傳到一個單一的線。我試圖用\n
分隔符:
docs <- read.table("log2.txt",header=FALSE,sep="\n",col.names="log",nrows=1000)
嘗試使用'readLines'代替。 – lmo