@@ -86,7 +86,7 @@ def all_values(self):
8686 it = self .__iter__ ()
8787
8888 for cell in it :
89- value = self ._grid .get_cell_value_by_index (cell ['c' ], cell ['r' ])
89+ value = self ._grid ._get_cell_value_by_numerical_index (cell ['c' ], cell ['r' ])
9090 values .append (value )
9191
9292 return values
@@ -331,24 +331,23 @@ def data(self, dataframe):
331331 'schema' : schema ,
332332 'fields' : [{field ['name' ]:None } for field in schema ['fields' ]]}
333333
334- def get_cell_value (self , column , row_index ):
335- """Gets the value for a single cell by column name and row index.
334+ def get_cell_value (self , column_name , primary_key_value ):
335+ """Gets the value for a single or multiple cells by column name and index name .
336336
337- Tuples should be used to index into multi-index columns.
337+ Tuples should be used to index into multi-index columns."""
338338
339- Note: The provided row_index should correspond to the row index in the
340- untransformed dataset."""
341-
342- return self ._data ['data' ][row_index ][column ]
339+ row_indices = self ._get_row_index_of_primary_key (primary_key_value )
340+
341+ return [self ._data ['data' ][row ][column_name ] for row in row_indices ]
343342
344- def set_cell_value (self , column , primary_key , value ):
343+ def set_cell_value (self , column_name , primary_key_value , new_value ):
345344 """Sets the value for a single cell by column name and primary key.
346345
347346 Note: This method returns a boolean to indicate if the operation
348347 was successful.
349348 """
350349
351- row_indices = self ._get_row_index_of_primary_key (primary_key )
350+ row_indices = self ._get_row_index_of_primary_key (primary_key_value )
352351
353352 # Bail early if key could not be found
354353 if not row_indices :
@@ -358,9 +357,9 @@ def set_cell_value(self, column, primary_key, value):
358357 else :
359358 op_success = []
360359 for row_index in row_indices :
361- if column in self ._data ['data' ][row_index ] and row_index is not None :
362- self ._data ['data' ][row_index ][column ] = value
363- self ._notify_cell_change (row_index , column , value )
360+ if column_name in self ._data ['data' ][row_index ] and row_index is not None :
361+ self ._data ['data' ][row_index ][column_name ] = new_value
362+ self ._notify_cell_change (row_index , column_name , new_value )
364363 op_success .append (True )
365364 else :
366365 op_success .append (False )
@@ -369,26 +368,21 @@ def set_cell_value(self, column, primary_key, value):
369368
370369 return False
371370
372- def get_cell_value_by_index (self , column_index , row_index ):
373- """Gets the value for a single cell by column index and row index."""
371+ def get_cell_value_by_index (self , column_name , row_index ):
372+ """Gets the value for a single cell by column name and row index."""
374373
375- column = self ._column_index_to_name (column_index )
376- if column is not None :
377- return self ._data ['data' ][row_index ][column ]
378-
379- return None
374+ return self ._data ['data' ][row_index ][column_name ]
380375
381- def set_cell_value_by_index (self , column_index , row_index , value ):
382- """Sets the value for a single cell by column index and row index.
376+ def set_cell_value_by_index (self , column_name , row_index , new_value ):
377+ """Sets the value for a single cell by column name and row index.
383378
384379 Note: This method returns a boolean to indicate if the operation
385380 was successful.
386381 """
387382
388- column = self ._column_index_to_name (column_index )
389- if column is not None and row_index >= 0 and row_index < len (self ._data ['data' ]):
390- self ._data ['data' ][row_index ][column ] = value
391- self ._notify_cell_change (row_index , column , value )
383+ if column_name in self ._data ['data' ][row_index ] and row_index >= 0 and row_index < len (self ._data ['data' ]):
384+ self ._data ['data' ][row_index ][column_name ] = new_value
385+ self ._notify_cell_change (row_index , column_name , new_value )
392386 return True
393387
394388 return False
@@ -603,3 +597,12 @@ def _get_row_index_of_primary_key(self, value):
603597 row_indices .append (i )
604598
605599 return row_indices
600+
601+ def _get_cell_value_by_numerical_index (self , column_index , row_index ):
602+ """Gets the value for a single cell by column index and row index."""
603+
604+ column = self ._column_index_to_name (column_index )
605+ if column is not None :
606+ return self ._data ['data' ][row_index ][column ]
607+
608+ return None
0 commit comments