Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Given a dataset, is there a way to modify a value?

Example

(*data = First@Import["dataset.xlsx"];*)
 data= {{"Supplier", "Material", "Geography", "Quantity"}, {"Acme", "A", 
  "United States", 676.}, {"Acme", "B", "Argentina", 520.}, {"Acme", 
  "C", "Russia", 186.}, {"Acme", "D", "France", 568.}, {"Acme", "E", 
  "United States", 201.}, {"Beta", "A", "Argentina", 483.}, {"Beta", 
  "D", "Russia", 289.}, {"Beta", "F", "France", 177.}, {"Beta", "G", 
  "United States", 169.}, {"Beta", "H", "Argentina", 842.}, {"Gamma", 
  "G", "Russia", 123.}, {"Gamma", "H", "France", 709.}, {"Gamma", "I",
   "United States", 579.}, {"Gamma", "J", "Argentina", 
  163.}, {"Gamma", "K", "Russia", 238.}, {"Delta", "A", "France", 
  405.}, {"Delta", "B", "United States", 411.}, {"Delta", "D", 
  "Argentina", 740.}, {"Delta", "H", "Russia", 322.}, {"Delta", "K", 
  "France", 321.}}

{fields, data} = {First[#], Rest[#]} &@data;
myDataset = 
  Dataset[Map[
    Association, (Rule[#[[1]], #[[2]]] & /@ Transpose[{fields, #}] & /@
       data)]];

Trying to update a value

myDataset[1, "Material"] = B

You'll get an error

Set::write: Tag Dataset in xxx [1,Material] is Protected.

share|improve this question

1 Answer 1

up vote 3 down vote accepted

This problem has already been discussed in this question. Taliesin Beynon said

As for when L-value assignment will be available, I'm hoping 10.0.1 or 10.0.2, which are in the next month or two.

share|improve this answer
1  
@Silvia 's answer discussed in the question you mention is a good workaround to address the issue observed. –  Zviovich Jul 16 at 15:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.