IsEndSplit Method (Python)
.IsEndSplit(). Indicates if the cursor position has crossed a split boundary. The result is Boolean—True if a split boundary has been crossed, otherwise False. This method is used in conjunction with the SplitChange function when creating custom pivot tables from data with splits.
- This method is available in read or write mode.
- The value returned from the
fetchone
method is None at a split boundary. Once a split has been detected, you will need to callfetchone
again to retrieve the first case of the next split group. -
IsEndSplit
returns True when the end of the dataset has been reached. Although a split boundary and the end of the dataset both result in a return value of True fromIsEndSplit
, the end of the dataset is identified by a return value of None from a subsequent call tofetchone
, as shown in the following example.
Example
GET FILE='/examples/data/employee data.sav'.
SORT CASES BY GENDER.
SPLIT FILE LAYERED BY GENDER.
BEGIN PROGRAM.
import spss
i=0
cur=spss.Cursor()
while True:
cur.fetchone()
i+=1
if cur.IsEndSplit():
# Try to fetch the first case of the next split group
if not None==cur.fetchone():
print("Found split end. New split begins at case: ", i)
else:
#There are no more cases, so quit
break
cur.close()
END PROGRAM.