I need to read a delimited file with | delimiter, whole characters quoted using "" and escape character as BACKSLASH.
The file data has 5 columns with Col1 .. Col5 where Col3 has values which are again delimited multiple values.
"Col1"|"Col2"|"Col3"|"Col4"|"Col5"
"Row1"|"aaaa"|"No Comment"|"1111"|"2018-07-02 00:00:01"
"Row2"|"bbbb"|"No Comment"|"2222"|"2019-08-02 00:00:01"
"Row3"|"cccc"|"No Comment"|"3333"|"2020-09-02 00:00:01"
"Row4"|"dddd"|"\"a1|b2|c3|d4|e5|f6|g7|h8|\""|"4444"|"2021-10-02 00:00:01"
"Row5"|"eeee"|"No Comment"|"5555"|"2022-11-02 00:00:01"
"Row6"|"ffff"|"\"a1|b2|c3|d4|e5|f6|g7|h8|\""|"6666"|"2023-10-02 00:00:01"
Row 4 has the value for Col 3 as - "a1|b2|c3|d4|e5|f6|g7|h8|"
and
Row 6 has the value for Col 3 as - "a1|b2|c3|d4|e5|f6|g7|h8|"
In Python, it can be read as
pd.read_csv('./test-file.txt', delimiter='|', doublequote=False, escapechar='\\', quoting=csv.QUOTE_ALL)
Please help me read it in R.
The following command in R
read.table("/test-file.txt", sep='|', quote = "\\", header=TRUE, allowEscapes = TRUE)
gives error
Error in read.table("/test-file.txt", :
more columns than column names