code: def save_grid_data(self):
          
          if not self.grid.changes:
              print('-I- No changes to save')
              return
  
          starred_cols = self.grid.remove_starred_labels()
          # locks in value in cell currently edited
          self.grid.SaveEditControlValue()
          # changes is a dict with key values == row number
          if self.grid.changes:
              new_data = self.grid.save_items()
              # HugeMagicGrid will return a pandas dataframe
              if self.huge:
                  self.magic_dataframe.df = new_data
              # MagicGrid will return a dictionary with
              # new/updated data that must be incorporated
              # into the dataframe
              else:
                  for key in new_data:
                      data = new_data[key]
                      # update the row if it exists already,
                      # otherwise create a new row
  
                      updated = self.magic_dataframe.update_row(key, data)
                      if not isinstance(updated, pd.DataFrame):
                          if self.grid_type == 'ages':
                              label = key
                          else:
                              label = self.grid_type[:-1]
                          self.magic_dataframe.add_row(label, data,
                                                       self.grid.col_labels)
              # update the contribution with the new dataframe
              self.contribution.tables[self.grid_type] = self.magic_dataframe
              # *** probably don't actually want to write to file, here (but maybe)
  
              self.contribution.write_table_to_file(self.grid_type)
              #self.magic_dataframe.write_magic_file("{}.txt".format(self.grid_type),
              #                                      self.contribution.directory)
              # propagate age info if age table was edited
              if self.grid_type == 'ages':
                  self.contribution.propagate_ages()
              return
docs: Save grid data in the data object