(defun finduniq (&optional (tbl (thetable))) (let ((i 0) (flag t) (uniq (list)) (tmp)) (dolist (row (therows tbl)) (if flag (progn (dolist (cell (row-cells row)) (setf uniq (append uniq (list (list cell))))) (setf flag nil)) (progn (dolist (cell (row-cells row)) (setf tmp (nth i uniq)) (unless (memberp cell tmp) (setf (nth i uniq) (append tmp (list cell)))) (incf i)))) (setf i 0)) uniq)) (defun tbl2dat (file &optional (tbl (thetable))) (let ((uniqs) (i 0)) (setf uniqs (finduniq tbl)) (with-open-file (stream file :direction :output :if-exists :overwrite :if-does-not-exist :create) (format stream "@relation ~a~%~%" (table-name tbl)) (print (length uniqs)) (dolist (col uniqs) (if (< i (- (length uniqs) 1)) (format stream "@attribute ~a " (remove #\$ (symbol-name (col-name (nth i (thecols tbl)))))) (format stream "@class ~a " (remove #\! (symbol-name (col-name (nth i (thecols tbl))))))) (dolist (cell col) (format stream "~a " cell)) (format stream "~%") (incf i)) (format stream "~%@data~%") (dolist (row (therows)) (dolist (cell (row-cells row)) (format stream "~a " cell)) (format stream "~%")) )))