我有一个包含SQL日志的文件,其中一小部分附加了here
data.table::fread
无法读取test.txt并突出显示此错误:
Error in fread("test.txt") :
Expected sep (' ') but new line, EOF (or other non printing character) ends field 0 when detecting types from point 0: "2017-10-28T06:44:52.057649Z 417 Query select term.class_session_id from class_sessions as term inner join tbl_auth as user on term.teacher_id = user.user_id where term.ends_on < now() and term.session_state=1 and TIME_TO_SEC(TIMEDIFF(term.ends_on,now())+0) < 3600 order by term.starts_on desc"
In addition: Warning message:
In fread("test.txt") :
Starting data input on line 2 and discarding line 1 because it has too few or too many items to be column names or data: "2017-10-28T06:44:52.054789Z 417 Query insert into event_log(service_name,user_id,UUID,xml_input,request_time) values('GetMyTodaysSessions','616','0','<Sunstone><Action><Service>GetMyTodaysSessions</Service><UserId>616</UserId></Action></Sunstone>','2017-10-28 12:14:52')"
据我所知,很少有这些行没有用引号括起来(&#34;&#34;)。
我们如何读取一个包含4列(制表符分隔)的文件,但有些行带引号而有些行没有?这是一个问题吗?
我可以理解fread
能够灵活地读取引号,并且实际上忽略了引号,但如果在引用文本之间遇到不带引号的文本,它似乎会失败。
我试图摆脱日志文件中没有引用的行,但是fread中的错误让我觉得缺少引号不是问题 - 它可能是别的。
有人可以查看test.txt,看看它是如何读入的吗?