I have evaluated a file and parsed through for only the lines I need. I saved these lines as a data frame and now am looking for a way to split it into columns for each field. My code for the data frame is below:
con <- file("dataSet.txt", "r")
lines <- c()
while(TRUE) {
line = readLines(con, 1)
if(length(line) == 0) break
else if(grepl("^\\s*F{1}", line) && grepl("(0,0)", line, fixed = TRUE))
lines <- c(lines, line)
}
lines <- data.frame(lines)
When lines is printed, it is displayed like this:
[1] F 20160525 08:22:06.838 F798256B GET 10.199.194.38:57708 wei2dt - "" "*li" 264 (0,0) "1.62 seconds (1.30 kilobits/sec)"
[2] F 20160525 08:28:26.920 F798256C GET 10.19.105.15:57708 wei2dt - "isi_audit_log.dmp-sv.tmp" "*dl" 69 (0,0) "0.29 seconds (1.93 kilobits/sec)"
[3] F 20160525 08:28:26.933 F798256E GET 10.19.105.15:57708 wei2dt - "CG0009-1364_GT_report.txt" "*dl" 34 (0,0) "0.01 seconds (34.0 kilobits/sec)"
[4] F 20160525 08:28:26.941 F798256F GET 10.19.105.15:57708 wei2dt - "./" "*li" 89 (0,0) "0.01 seconds (102 kilobits/sec)"
[5] F 20160525 08:29:12.717 7798256B SEND 10.19.105.15:57708 wei2dt - "isi_audit_log.dmp" "" 1019692009 (0,0) "38.05 seconds (214 megabits/sec)"
1741 Levels: F 20160525 08:22:06.838 F798256B GET 10.199.194.38:57708 wei2dt - "" "*li" 264 (0,0) "1.62 seconds (1.30 kilobits/sec)"
However, I would like to split up lines into multiple columns so that each field (separated by a space) is in it's own column. Specifically, I want to split it into 13 columns labelled:
"Line ID"
"Date"
"Timestamp"
"Transfer ID"
""
"IP Address"
"Username"
"Encryption Level"
"Transferred File"
""
"Transferred Bytes"
"Error"
"Transfer Time Data"
The ones with blank strings indicate columns that I do not want to name. I want to split the rest into the columns above like so:
F -- identifier of the line
20160525 -- date (yyyymmdd)
17:52:38.791 -- timestamp (HH:MM:SS.sss)
F798259D -- transfer identifier
156.145.15.85:46634 -- IP address and related port
xqixh8sl -- username
AES -- encryption level (could be - (dash))
"/pcgc...fastq.gz" -- transferred file (in ")
"" -- additional string (should be empty "")
2951144113 -- transferred bytes
(0,0) -- error (only consider lines with 0,0 for now)
"2289.47 seconds (10.3 megabits/sec)" -- data about the transfer
Thank you for your help in advance.
UPDATE
As requested, I will put the result of dput(head(lines, 10)) below.
"F 20160531 14:19:11.085 F7982871 GET 146.203.126.246:31947 xricf4xj AES \"/pcgc/public/Other/transcriptome/fastq/PCGC0069603_HS_TX__1-05846__v1_FC882_L2_p9of16_P2.fastq.gz\" \"\" 551700712 (0,0) \"12.42 seconds (355 megabits/sec)\""
"F 20160531 14:19:24.085 F7982872 GET 146.203.126.246:20198 xricf4xj AES \"/pcgc/public/Other/transcriptome/fastq/PCGC0069749_HS_TX__1-04056__v1_FC01060_L1_p3of12_P2.fastq.gz\" \"\" 592956993 (0,0) \"12.98 seconds (365 megabits/sec)\""
"F 20160531 14:20:04.881 F7982873 GET 146.203.126.246:37792 xricf4xj AES \"/pcgc/public/Other/transcriptome/fastq/PCGC0065337_HS_TX__1-02281__v1_FC504_L5_p4of6_P2.fastq.gz\" \"\" 1787507416 (0,0) \"40.76 seconds (351 megabits/sec)\""
"F 20160531 14:20:10.763 F7982874 GET 146.203.126.246:5683 xricf4xj AES \"/pcgc/public/Other/transcriptome/fastq/PCGC0065271_HS_TX__1-02626__v1_FC412_L1_p6of6_P2.fastq.gz\" \"\" 235573426 (0,0) \"5.86 seconds (321 megabits/sec)\""
"F 20160531 14:20:24.142 F7982875 GET 146.203.126.246:52946 xricf4xj AES \"/pcgc/public/CTD/transcriptome/fastq/PCGC0069557_HS_TX__1-00738__v1_FC864_L1_p3of7_P2.fastq.gz\" \"\" 619011108 (0,0) \"13.34 seconds (371 megabits/sec)\""
"F 20160531 14:20:36.823 F7982876 GET 146.203.126.246:12531 xricf4xj AES \"/pcgc/public/CTD/transcriptome/fastq/PCGC0065398_HS_TX__1-01907__v1_FC718_L1_p2of10_P1.fastq.gz\" \"\" 539231282 (0,0) \"12.63 seconds (341 megabits/sec)\""
"F 20160531 14:21:10.955 F7982877 GET 146.203.126.246:2531 xricf4xj AES \"/pcgc/public/LVOTO/transcriptome/fastq/PCGC0065300_HS_TX__1-00652__v1_FC437_L3_p1of6_P2.fastq.gz\" \"\" 1545568612 (0,0) \"34.10 seconds (363 megabits/sec)\""
"F 20160531 14:21:20.721 F7982878 GET 146.203.126.246:16699 xricf4xj AES \"/pcgc/public/Other/transcriptome/fastq/PCGC0065413_HS_TX__1-01894__v1_FC718_L1_p6of10_P1.fastq.gz\" \"\" 452830134 (0,0) \"9.73 seconds (372 megabits/sec)\""
"F 20160531 14:21:26.191 F7982879 GET 146.203.126.246:54154 xricf4xj AES \"/pcgc/public/Other/transcriptome/fastq/PCGC0065397_HS_TX__1-01894__v1_FC711_L2_p6of10_P2.fastq.gz\" \"\" 267729030 (0,0) \"5.45 seconds (393 megabits/sec)\""
"F 20160531 14:21:41.752 F798287A GET 146.203.126.246:55620 xricf4xj AES \"/pcgc/public/Other/transcriptome/fastq/PCGC0069744_HS_TX__1-05476__v1_FC971_L2_p1of12_P2.fastq.gz\" \"\" 670588883 (0,0) \"15.54 seconds (345 megabits/sec)\""