From add54fe3a638577866f8bd7623616bb8ff6eb2e2 Mon Sep 17 00:00:00 2001 From: AJ Rossini Date: Wed, 11 Mar 2009 06:15:33 +0100 Subject: [PATCH] examples using cybertiggyr-dsv package. Need a string->numeric converter. Signed-off-by: AJ Rossini --- TODO.lisp | 21 ++++++++++++++++++--- src/data/dsv-cybertiggyr.lisp | 14 ++++++++++---- src/packages.lisp | 5 +++-- 3 files changed, 31 insertions(+), 9 deletions(-) diff --git a/TODO.lisp b/TODO.lisp index 394eeb3..6ca43e7 100644 --- a/TODO.lisp +++ b/TODO.lisp @@ -1,6 +1,6 @@ ;;; -*- mode: lisp -*- -;;; Time-stamp: <2009-03-10 21:38:11 tony> +;;; Time-stamp: <2009-03-11 06:12:57 tony> ;;; Creation: <2008-09-08 08:06:30 tony> ;;; File: TODO.lisp ;;; Author: AJ Rossini @@ -205,11 +205,26 @@ (progn ;; FIXME: read data from CSV file. To do. + ;; challenge is to ensure that we get mixed arrays when we want them, ;; and single-type (simple) arrays in other cases. - (defparameter *csv-num* (read-csv "Data/example-num.csv" :type 'numeric)) - (defparameter *csv-mix* (read-csv "Data/example-mixed.csv" :type 'data)) + + (defparameter *csv-num* + (cybertiggyr-dsv::load-escaped + #p"/media/disk/Desktop/sandbox/CLS.git/Data/example-numeric.csv" + :field-separator #\, + :trace T)) + + (nth 0 (nth 0 *csv-num*)) + + (defparameter *csv-num* + (cybertiggyr-dsv::load-escaped + #p"/media/disk/Desktop/sandbox/CLS.git/Data/example-numeric2.dsv" + :field-separator #\:)) + + (nth 0 (nth 0 *csv-num*)) + ;; The handling of these types should be compariable to what we do for ;; matrices, but without the numerical processing. i.e. mref, bind2, diff --git a/src/data/dsv-cybertiggyr.lisp b/src/data/dsv-cybertiggyr.lisp index 5e432ff..569fd58 100644 --- a/src/data/dsv-cybertiggyr.lisp +++ b/src/data/dsv-cybertiggyr.lisp @@ -19,9 +19,9 @@ ;;; USA ;;; -(defpackage "CYBERTIGGYR-DSV" - (:use "COMMON-LISP") - (:import-from "CYBERTIGGYR-TEST" "DEFTEST") +(defpackage :cybertiggyr-dsv + (:use :common-lisp) + (:import-from :cybertiggyr-test "DEFTEST") (:export "*END-OF-RECORD*" "*ESCAPE*" "*FIELD-SEPARATOR*" @@ -96,7 +96,13 @@ character. Since NIL is not a character, it will never be equal to a character read from STRM, so there will be no possible escape character. In fact, you could use any non-character to disable the escape character. Ignors empty lines. On end-of-input, returns STRM. It is -an error if an escape character is followed by end-of-input." +an error if an escape character is followed by end-of-input. + + + (with-open-stream (s (make-stream-from-file \"test.csv\")) + (loop (read-escaped s) collecting result)) + +" (consume-leading-crap strm end-of-record) (if (eq (xpeek strm) strm) strm ; normal end-of-input diff --git a/src/packages.lisp b/src/packages.lisp index 3598d27..5a2a91b 100644 --- a/src/packages.lisp +++ b/src/packages.lisp @@ -1,6 +1,6 @@ ;;; -*- mode: lisp -*- -;;; Time-stamp: <2009-03-10 08:43:49 tony> +;;; Time-stamp: <2009-03-11 05:53:30 tony> ;;; Creation: <2008-03-11 19:18:34 user> ;;; File: packages.lisp ;;; Author: AJ Rossini @@ -328,7 +328,8 @@ :lisp-stat-math :lisp-matrix ;; conversion to a more robust linalg approach :lisp-stat-descriptive-statistics - :lisp-stat-regression-linear) + :lisp-stat-regression-linear + :cybertiggyr-dsv) (:shadowing-import-from :lisp-stat-object-system slot-value call-method call-next-method) (:shadowing-import-from :lisp-stat-math -- 2.11.4.GIT