From e5b0de99e2973ddaf0317a8e595de6dbd40353e7 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Sun, 11 May 2025 21:39:27 -0400 Subject: [PATCH] partial definition of pt-build --- pivot-table.el | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/pivot-table.el b/pivot-table.el index 2797a98..fffbedc 100644 --- a/pivot-table.el +++ b/pivot-table.el @@ -23,6 +23,32 @@ ;;; Code: +(defun pt-build (source &key rows cols vals) + "Build a pivot table + +The SOURCE value should be the table the data is being taken +from. ROWS and COLS should be lists of column references from +the source table to be used as rows and columns for the pivot +table. These can either be integers representing the column +number, or strings representing column names. + +VALUES should be a list containing information about the values +in the body of the pivot table. Each element of the list should +be in the following format (REF FUNC &optional LABEL). + +TODO: more documentation" + (let ((col-index (pt-get-columns source)) + (index (pt-column-names source)) + src-cols + (src-body (pt-get-body source)) + (buckets (make-hash-table))) + (pt--index-columns rows) + (pt--index-columns cols) + (pt--index-columns vals car) + (sort src-cols #'<) + (dolist (record src-body) + (pt--process-record record source-cols buckets)))) + ;; Local Variables: ;; read-symbol-shorthands: (("pt-" . "pivot-table-")) ;; End: