naveen naveen - 29 days ago 4
R Question

how to read dat file in R which is having different seperators

here is the sample dataset
Here the problem is the seperator is :: but inbetween the movie name there is ":" so i am getting problem with this
please help me outenter image description here

here is the dataset


You could try to do the following:

input <- data.table(,strsplit(readLines('file.txt'),'::' )))
input[, c("V3", "V4", "V5") := tstrsplit(V3, split = "|", fixed = T)]

The first line reads your file ("file.txt" should be substituted with your file name) using the :: as a separator. The second line splits the 1 column that contains all the classifications into 3 separate columns.