diff --git a/docs/src/data/semicolon-quoted.txt b/docs/src/data/semicolon-quoted.txt new file mode 100644 index 000000000..0888d79de --- /dev/null +++ b/docs/src/data/semicolon-quoted.txt @@ -0,0 +1,2 @@ +a;b +"text; text";"more text" diff --git a/docs/src/file-formats.md b/docs/src/file-formats.md index ef1eacd8b..7a38f0da5 100644 --- a/docs/src/file-formats.md +++ b/docs/src/file-formats.md @@ -836,6 +836,41 @@ the dawn's light +Note that NIDX and DKVP split each line on the field separator without regard to double quotes: a separator inside a double-quoted string still starts a new field. + +
+cat data/semicolon-quoted.txt
+
+
+a;b
+"text; text";"more text"
+
+ +
+mlr --inidx --ifs semicolon --oxtab cat data/semicolon-quoted.txt
+
+
+1 a
+2 b
+
+1 "text
+2  text"
+3 "more text"
+
+ +If your data uses RFC-4180-style double-quoting to protect separators inside field values, use CSV format with `--ifs` set to your separator -- along with `--implicit-csv-header` if the file has no header line: + +
+mlr --icsv --ifs semicolon --implicit-csv-header --oxtab cat data/semicolon-quoted.txt
+
+
+1 a
+2 b
+
+1 text; text
+2 more text
+
+ ## DCF (Debian control file)
diff --git a/docs/src/file-formats.md.in b/docs/src/file-formats.md.in
index 90cfc846f..c739618e1 100644
--- a/docs/src/file-formats.md.in
+++ b/docs/src/file-formats.md.in
@@ -409,6 +409,22 @@ GENMD-RUN-COMMAND
 mlr --nidx --fs ' ' --repifs cut -f 2,3 data/mydata.txt
 GENMD-EOF
 
+Note that NIDX and DKVP split each line on the field separator without regard to double quotes: a separator inside a double-quoted string still starts a new field.
+
+GENMD-RUN-COMMAND
+cat data/semicolon-quoted.txt
+GENMD-EOF
+
+GENMD-RUN-COMMAND
+mlr --inidx --ifs semicolon --oxtab cat data/semicolon-quoted.txt
+GENMD-EOF
+
+If your data uses RFC-4180-style double-quoting to protect separators inside field values, use CSV format with `--ifs` set to your separator -- along with `--implicit-csv-header` if the file has no header line:
+
+GENMD-RUN-COMMAND
+mlr --icsv --ifs semicolon --implicit-csv-header --oxtab cat data/semicolon-quoted.txt
+GENMD-EOF
+
 ## DCF (Debian control file)
 
 GENMD-RUN-COMMAND