Skip to main content
7 of 12
added 1 character in body
Alexey Popkov
  • 62.3k
  • 7
  • 154
  • 375

According to the Documentation, "TextDelimiters" determines "string or list of strings used to delimit non-numeric fields." Based on this I would consider the following behavior as a bug ("TextDelimiters" option is ignored for the NumberString fields wrapped by the specified text delimeters):

ImportString["0000123,\"0000123\"", "CSV", "TextDelimiters" -> "\""]
{{123, 123}}

Below is what I would consider as correct behavior of Import according to the Docs:

ImportString["0000123,\"0000123\"", "CSV", "TextDelimiters" -> "\""]
{{123, "0000123"}}

The Documentation statement

Double-quote characters delimiting text fields are not imported by default.

is completely in accord with my interpretation: with the option "TextDelimiters" -> "\"" the textual field above should be imported as "0000123" (i.e. without the double-quotes inside of the string).


With "TextDelimiters" -> None you can achieve almost what you wish:

ImportString["0,\"a\",\"0\"
1,\"c\",\"xyz\"", "CSV", "TextDelimiters" -> None]
{{0, "\"a\"", "\"0\""}, {1, "\"c\"", "\"xyz\""}}

But a post-processing step is still necessary:

% /. s_String :> StringTake[s, {2, -2}]
{{0, "a", "0"}, {1, "c", "xyz"}}
Alexey Popkov
  • 62.3k
  • 7
  • 154
  • 375