I'm trying to Export a simple dataset with key-value pairs to a CSV
Export["n.csv", MyDataset, "CSV"]
This results in a single-line serialization:
Dataset[<|"A" -> 3757, "B" -> 426, "C" -> 193, ...."D" -> 1|>, TypeSystem`Assoc[TypeSystem`Atom[String], TypeSystem`Atom[Integer], 15], <|"Origin" -> HoldComplete[Sort[Dataset`DatasetHandle[265575026537634], Greater]], "ID" -> 109770792907938|>]
The desired result is:
A,3757
B,426
C,193
...
D,1
Answer
Here is one option:
ds = Dataset[<|"A" -> 3757, "B" -> 426, "C" -> 193, "D" -> 1|>]
Now, to create the CSV you can use:
Export["text.csv", List@@@Normal@Normal@ds]
Comments
Post a Comment