Group Abstract Group Abstract

Message Boards Message Boards

0
|
13.3K Views
|
3 Replies
|
8 Total Likes
View groups...
Share
Share this post:

Export strings without quotes to a .csv?

Posted 8 years ago
POSTED BY: Robert McHugh
3 Replies

Set the option "TextDelimiters":

Export["data.csv",{{"a\nb", "c", "d"}}, "CSV", "TextDelimiters" -> ""]
POSTED BY: Sander Huisman
Posted 8 years ago

Thanks Neil,

That does address the first question very nicely!

As for the follow-up question, in the example below, the output has two set of double quotes like this: text with""quoted text"" . The goal would be to have only one set of double quotes, like this: text with "quoted text"

row0 = {"h1", "h2", "h3", "h4", "h5", "h6"};
row1 = {"", "", "a1", 1.01, "", ""};
row2 = {"", "", "b1", 2.02, "", "text with \"quoted text\" "};
row3 = {"", "", "c1", 3.03, "", ""};
data = {row0, row1, row2, row3};
Export["data.csv", data, "TextDelimiters" -> ""]; 

Output is the following

h1,h2,h3,h4,h5,h6
,,a1,1.01,,
,,b1,2.02,,text with ""quoted text"" 
,,c1,3.03,, 

, just need to change the "" to "

POSTED BY: Robert McHugh

Robert,

Use the option

"TextDelimiters"->""

in the command

Export["data.csv", data, "TextDelimiters"->""];

There are many CSV file options (and for all the other Export file options as well). The documentation for them is here. As for your followup question, I'm not sure what you are asking.

Regards,

Neil

POSTED BY: Neil Singer
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard