I need to parse a txt file like this:
2021 Sep 27 15:54:50 avg_dur = 0.321 s
2021 Sep 27 15:54:52 avg_dur = 0.036 s
2021 Sep 27 15:54:54 avg_dur = 0.350 s
2021 Sep 27 15:54:56 avg_dur = 0.317 s
I am interest in parsing the date and the number in a R data frame. I am trying a parser like this (only for the date):
df <- read_table("myFile.txt", col_names = FALSE, col_types = cols(X1 = col_datetime(format = "%Y %b %d %H:%M:%S")))
But it doesn't work:
Warning: 31502 parsing failures.
row col expected actual file
1 X1 date like %Y %b %d %H:%M:%S 2021 'uclStats/91.211.159.43-dash_d1_gwv_vos-u5.log-avg'
2 X1 date like %Y %b %d %H:%M:%S 2021 'uclStats/91.211.159.43-dash_d1_gwv_vos-u5.log-avg'
3 X1 date like %Y %b %d %H:%M:%S 2021 'uclStats/91.211.159.43-dash_d1_gwv_vos-u5.log-avg'
4 X1 date like %Y %b %d %H:%M:%S 2021 'uclStats/91.211.159.43-dash_d1_gwv_vos-u5.log-avg'
5 X1 date like %Y %b %d %H:%M:%S 2021 'uclStats/91.211.159.43-dash_d1_gwv_vos-u5.log-avg'
... ... ........................... ...... ...................................................
See problems(...) for more details.
The problem is clearly that it's trying to parse the first column with the recipe of the whole date time.
Which is the correct way to parse this txt file in a data frame?
Regards, S.