<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def dovds(data):
 """ calculates vector difference sum for demagnetization data """

    vds, X = 0, []
    for rec in data:
        X.append(dir2cart(rec))
    for k in range(len(X) - 1):
        xdif = X[k + 1][0] - X[k][0]
        ydif = X[k + 1][1] - X[k][1]
        zdif = X[k + 1][2] - X[k][2]
        vds += np.sqrt(xdif**2 + ydif**2 + zdif**2)
    vds += np.sqrt(X[-1][0]**2 + X[-1][1]**2 + X[-1][2]**2)
    return vds