R语言分隔日志文件,出现问题
功能:用R语言根据','分隔日志,但是日志里面的','不一定有规律。
R:
F1 <- "C:/Documents and Settings/Administrator/桌面/r/log.txt"
A1<-read.csv(file=F1, header=FALSE, sep=",", stringsAsFactors=FALSE)
A1<-na.omit(A1)
日志文件log.txt(由于篇幅问题,这里原本一行的日志显示成了两行,一行日志包括时间,code,na,in,fi,date,ph):
2013-12-09 19:00:42 code:008, na=saff asd,asdas,fdsfsdfsd,gdfgdf,sd, in=0.0, fi=0.0, date=null, ph=263771843617
2013-12-09 19:39:56 code:010, na=sadsafsdf ,dgd,bfoasd gh,m,,,,,,f,f,f,h,,f,dsfsdf, in=0.0, fi=0.0, date=null, ph=263774851386
2013-12-09 19:00:42 code:008, na=saff asd,asdas,fd,sfsdfsd,gdfgdf,sd, in=0.0, fi=0.0, date=null, ph=263771843617
2013-12-09 19:39:56 code:010, na=sadsafsdf ,dgdfb,foasd ,dsfsdf, in=0.0, fi=0.0, date=null, ph=263774851386
2013-12-09 19:00:42 code:008, na=saff asd,asdas,fdsfsdfsd,gdfgdf,sd, in=0.0, fi=0.0, date=null, ph=263771843617
2013-12-09 19:39:56 code:010, na=sadsafsdf ,dgdfb,foasd ,dsfsdf, in=0.0, fi=0.0, date=null, ph=263774851386
现在是因为有些日志里面','很不规律,比如日志第二行中','有很多,导致R分隔文件错误?
A1$V1
character(0)
A1
[1] V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 V13 V14 V15 V16 V17 V18 V19 V20 V21
<0 行> (或0-长度的row.names)
正常的话应该第一列是:
2013-12-09 19:00:42 code:008
2013-12-09 19:39:56 code:010
2013-12-09 19:00:42 code:008
2013-12-09 19:39:56 code:010
2013-12-09 19:00:42 code:008
2013-12-09 19:39:56 code:010
求原因?谢谢!