I need to read a file with R where a variable number of columns is separated by | . However, if preceded by a \ , this should not be construed as a delimiter.
At first I thought that something like strsplit(x, "[^\\][|]") would work, but the problem here is that the character before each pipe is "consumed":
> strsplit("word1|word2|word3\\|aha!|word4", "[^\\][|]") [[1]] [1] "word" "word" "word3\\|aha" "word4"
Can anyone suggest a way to do this? Ideally, it should be vectorized because the files in question are very large.
source share