8
$\begingroup$

Would like to export a List of Lists to a CSV file.

Would like the strings in the exported file to not have quotes around them, which doesn't appear to be the default behavior. Is there an option that will produce this behavior?

The answer is the TextDelimiters option will control this behavior, as shown below.

Export[FileNameJoin[{NotebookDirectory[], 
   "testOut.csv"}], testData, "CSV", TextDelimiters -> ""]

An answer to this question is provided here: Export strings without the quotes ; however, a simple search of the Mathematica Stack Exchange site, with "Export" and "CSV" will not identify this previously submitted answer.

Also, as noted in the comments below, this option is described on the Mathematica Help page for CSV; however, it is not described on the Mathematica Help page for Export

Below is a test list with numbers and strings:

testDataRow1 = {"aa1", 1.1, 13, "1.41", "aa5"};
testDataRow2 = {"bb1", 2.2, 23, "2.423" , "bb5"}; 
testDataRow3 = {"cc1", 3.2, 33, "3.423" , "cc5"}; 
testData = {testDataRow1, testDataRow2, testDataRow3};

Export without the TextDelimiters option

Export[FileNameJoin[{NotebookDirectory[], "testOut.csv"}], testData]

produces a .csv file has quotes around the strings:
Result of Export to a .csv

Export with the TextDelimiters option, shown below,

Export[FileNameJoin[{NotebookDirectory[], 
   "testOut.csv"}], testData, "CSV", TextDelimiters -> ""]

produces the desired result

Output CSV file with TextDelimiters option set

$\endgroup$
2

0