append Method (Python)
.append(case). Appends a new case to the associated dataset and appends an element representing the case to the corresponding CaseList instance. The argument case is a tuple or list specifying the case values. The first element in the tuple or list is the value for the first variable in file order, the second is the value of the second variable in file order and so on.
- The elements of case can be numeric or string values and must match the variable type of the associated variable. Values of None are converted to system-missing for numeric variables and blanks for string variables.
- Values of numeric variables with a
date or datetime format should be specified as Python
time.struct_time
ordatetime.datetime
objects, which are then converted to the appropriate IBM® SPSS® Statistics value. Values of variables withTIME
andDTIME
formats should be specified as the number of seconds in the time interval.
Example
DATA LIST FREE/numvar (F2) strvar (A1).
BEGIN DATA.
1 a
END DATA.
BEGIN PROGRAM.
import spss
spss.StartDataStep()
datasetObj = spss.Dataset()
# Append a single case to the active dataset
datasetObj.cases.append([2,'b'])
spss.EndDataStep()
END PROGRAM.