@@ -8957,23 +8957,35 @@ def append_db_case(self, db: "DataKit", i: int):
89578957 self .append_col (col , db .get_values (col , i ), nref = n )
89588958
89598959 # Append data to multiple columns
8960- def xappend (self , d : dict , nref : Optional [int ] = None ):
8960+ def xappend (
8961+ self ,
8962+ d : dict ,
8963+ nref : Optional [int ] = None ,
8964+ update : bool = True ):
89618965 r"""Append data to multiple columns
89628966
89638967 This works for scalars, lists, 1D arrays, and *N*-D arrays
89648968
89658969 :Call:
8966- >>> db.xappend(d)
8970+ >>> db.xappend(d, nref=None, update=True )
89678971 :Inputs:
89688972 *db*: :class:`DataKit`
89698973 Data interface with response mechanisms
89708974 *d*: :class:`dict`
89718975 Dictionary of cols (keys) and values to append
8976+ *nref*: {``None``} | :class:`int`
8977+ Predetermined reference size
8978+ *update*: {``True``} | ``False``
8979+ Option to reduce ref size by 1
89728980 :Versions:
89738981 * 2025-07-23 ``@ddalle``: v1.0
8982+ * 2025-09-19 ``@ddalle``: v1.1; add *update*
89748983 """
89758984 # Get current reference size
8976- n = nref if nref is not None else self .get_refsize ()
8985+ refsize = self .get_refsize ()
8986+ refsize = max (0 , refsize - 1 ) if update else refsize
8987+ # Use user input if given
8988+ n = nref if nref is not None else refsize
89778989 # Loop through cols of *d*
89788990 for col , v in d .items ():
89798991 self .append_col (col , v , nref = n )
0 commit comments