The help file for format/Table says very clearly

"By default, Export delimits text fields containing the field separator with double-quote characters."

A simple test shows this statement is not true:

data = {{"ab", 1}, {"dd", 2}};
Export["test.txt", data, "Table"]

I know it can be corrected by

Export["test.txt", data, "Table","TextDelimiters" -> "\""]

but again, the behaviour should be by default and this does not seem right. (also note that changing file-type to dat does not help).

This is happening on Mathematica 11.3 for Linux.

Can anyone confirm this is a bug?



The documentation is fine, there is no bug, use "TSV" instead of "Table".

Longer explanation

The documentation for Table reads

By default, Export delimits text fields containing the field separator with double-quote characters.

Example when the field does not contain a field separator ("\t")

ExportString[{{"ab", 1}, {"dd", 2}}, "Table"]

Mathematica graphics

Example when a field does contain a field separator ("\t")

ExportString[{{"a\tb", 1}, {"dd", 2}}, "Table"]

Mathematica graphics

And therefore the behaviour is exactly as described in the documentation.


If you want quotation marks always and by default, use "TSV"

ExportString[{{"ab", 1}, {"dd", 2}}, "TSV"]

Mathematica graphics


In a related topic discussed here, formats like "CSV" are not a general standard and Mathematicas's implementation is as good as any other in principle. Nevertheless, RFC 4180 defines the following

  1. Fields containing line breaks (CRLF), double quotes, and commas should be enclosed in double-quotes. For example:

    "aaa","b CRLF bb","ccc" CRLF zzz,yyy,xxx

where CRLF stands for "carriage return" and "line feed" characters.

But Mathematica ignores that interpretation when doing Import and line or fields separators within quotations marks may be considered real separators instead of part of the fields.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for?Browse other questions tagged or ask your own question.