sub and gsub: how to use "\n" in replace
Hi,
if I run echo "a=lorem" | mlr --ocsv sub -a "r" "\n"
I get this without carriage return
a
lo\nem
Shouldn't I also have in output with sub and gsub the ability to use these special chars?
Thank yoy
Does csv "standard" support newlines in cells? I think it does, but maybe check with less strict format..
Does csv "standard" support newlines in cells?
Yes, it does, and I think this is a small bug. But maybe I am wrong and I am waiting (as soon as possible) for a check from @johnkerl
Yes, RFC-4180 CSV supports newline within double-quoted cells: https://miller.readthedocs.io/en/6.13.0/file-formats/#csvtsvasvusvetc
Note that normally \r and/or \n are not within cells, they're delimiters between them.
It's a bug that
echo "a=lorem" | mlr --ocsv sub -a "r" "\n"
produces a cell with \n contained within it, and that that cell isn't being double-quoted as it should be.
It's a bug that
echo "a=lorem" | mlr --ocsv sub -a "r" "\n"produces a cell with
\ncontained within it, and that that cell isn't being double-quoted as it should be.
Do I need to open a new issue for this bug, or can we use this?
Thank you @johnkerl
I'll use this issue -- thanks @aborruso !
A workaround is using embedded newline, e.g.:
$ echo "a=lorem" | mlr --ocsv sub -a "r" $'\n'
a
"lo
em"
or:
$ echo "a=lorem" | mlr --ocsv sub -a "r" '
'
a
"lo
em"
Thank you very much @agguser