Skip to main content
edited tags
Link
ecoxlinux
  • 979
  • 4
  • 10
Source Link
ecoxlinux
  • 979
  • 4
  • 10

Failure when exporting dataset with real-valued cells

Consider the following dataset:

dat = Dataset[<| "A" -> 1, "B" -> 2|>];
ExportString[dat, "CSV"]

It exports perfectly, with the expected result:

(* "A",1
   "B",2 *)

The above also works fine if the cells of the dataset are strings:

dat = Dataset[<| "A" -> "1", "B" -> "2"|>];

However, if the cells are reals (only one of them seems to be enough), then

dat = Dataset[<| "A" -> 1.0, "B"-> 2.0 |>];
ExportString[dat, "CSV"]

returns $Failed, with the following message:

Dataset::exportfail: Dataset of the given form could not be exported as format "CSV".

The same issue appears when using Export rather than ExportString. I am currently using ToString to convert all cells to strings before exporting. Is this a bug?

I am using OS X, Mathematica version 11.