The data-table Reference Manual

Next: , Previous: , Up: (dir)   [Contents][Index]

The data-table Reference Manual

This is the data-table Reference Manual, version 0.1, generated automatically by Declt version 4.0 beta 2 "William Riker" on Tue Nov 15 05:32:27 2022 GMT+0.

Table of Contents


1 Introduction

Data Table

A Common Lisp library providing a data-table data-structure that has rows of data and column names and types

Goals

Authors

;; Copyright (c) 2011 Russ Tyndall , Acceleration.net http://www.acceleration.net
;; All rights reserved.
;;
;; Redistribution and use in source and binary forms, with or without
;; modification, are permitted provided that the following conditions are
;; met:
;;
;;  - Redistributions of source code must retain the above copyright
;;    notice, this list of conditions and the following disclaimer.
;;
;;  - Redistributions in binary form must reproduce the above copyright
;;    notice, this list of conditions and the following disclaimer in the
;;    documentation and/or other materials provided with the distribution.
;;
;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
;; A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT
;; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
;; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
;; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
;; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

2 Systems

The main system appears first, followed by any subsystem dependency.


Previous: , Up: Systems   [Contents][Index]

2.1 data-table

A library providing a data-table class, and useful functionality around this

License

BSD

Version

0.1

Dependencies
  • iterate (system).
  • symbol-munger (system).
  • alexandria (system).
  • cl-interpol (system).
Source

data-table.asd.

Child Component

data-table.lisp (file).


3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

3.1 Lisp


Next: , Previous: , Up: Lisp   [Contents][Index]

3.1.1 data-table/data-table.asd

Source

data-table.asd.

Parent Component

data-table (system).

ASDF Systems

data-table.

Packages

data-table.system.


3.1.2 data-table/data-table.lisp

Source

data-table.asd.

Parent Component

data-table (system).

Packages

data-table.

Public Interface
Internals

4 Packages

Packages are listed by definition order.


Next: , Previous: , Up: Packages   [Contents][Index]

4.1 data-table.system

Source

data-table.asd.

Use List
  • asdf/interface.
  • common-lisp.

Previous: , Up: Packages   [Contents][Index]

4.2 data-table

Source

data-table.lisp.

Use List
  • common-lisp.
  • common-lisp-user.
  • iterate.
Public Interface
Internals

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

5.1 Public Interface


5.1.1 Special variables

Special Variable: *guessing-types-sample-size*

how many rows to look at when trying to guess the types for each column of a data table

Package

data-table.

Source

data-table.lisp.


5.1.2 Ordinary functions

Function: add-column (dt column-name &optional default column-type index)

Adds a new column to the data table passed in

Package

data-table.

Source

data-table.lisp.

Function: alists-to-data-table (list-of-alists &key test keys)

given a list of alists, (all with the same keys) convert them to a data-table

Package

data-table.

Source

data-table.lisp.

Function: coerce-data-table-of-strings-to-types (dt)

Figure out what the data-table-types should be then convert all the data in the table to those types

Package

data-table.

Source

data-table.lisp.

Function: coerce-data-table-values-for-output (dt &key output-type)

Coerce for output all the values in all the rows and return the new rows

Package

data-table.

Source

data-table.lisp.

Function: coerce-data-table-values-for-output! (dt &key output-type)

Coerce for output all the values in all the rows and save the result to the rows slot

Package

data-table.

Source

data-table.lisp.

Function: column-index (col dt)
Package

data-table.

Source

data-table.lisp.

Function: column-name (col dt)
Package

data-table.

Source

data-table.lisp.

Function: (setf column-name) (col dt)
Package

data-table.

Source

data-table.lisp.

Function: column-type (col dt)
Package

data-table.

Source

data-table.lisp.

Function: (setf column-type) (col dt)
Package

data-table.

Source

data-table.lisp.

Function: data-table-to-alists (dt)
Package

data-table.

Source

data-table.lisp.

Function: data-table-to-plists (dt)
Package

data-table.

Source

data-table.lisp.

Function: plists-to-data-table (list-of-plists &key keys)
Package

data-table.

Source

data-table.lisp.

Function: select-columns (table column-names)

returns a new data table with only the columns requested, by name

Package

data-table.

Source

data-table.lisp.


5.1.3 Generic functions

Generic Function: coerce-value-for-output (dt column-name val output-type)
Package

data-table.

Methods
Method: coerce-value-for-output ((dt data-table) column-name val output-type)

Coerce a data-tables-value to a specified output format.
By default only strings are supported. This method is intended to be extended in other applications to allow mutating to html / csv / etc

Source

data-table.lisp.

Generic Reader: column-names (object)
Package

data-table.

Methods
Reader Method: column-names ((data-table data-table))

automatically generated reader method

Source

data-table.lisp.

Target Slot

column-names.

Generic Writer: (setf column-names) (object)
Package

data-table.

Methods
Writer Method: (setf column-names) ((data-table data-table))

automatically generated writer method

Source

data-table.lisp.

Target Slot

column-names.

Generic Reader: column-types (object)
Package

data-table.

Methods
Reader Method: column-types ((data-table data-table))

automatically generated reader method

Source

data-table.lisp.

Target Slot

column-types.

Generic Writer: (setf column-types) (object)
Package

data-table.

Methods
Writer Method: (setf column-types) ((data-table data-table))

automatically generated writer method

Source

data-table.lisp.

Target Slot

column-types.

Generic Function: data-table-data-compare (dt1 dt2 &key test key)
Package

data-table.

Methods
Method: data-table-data-compare (dt1 dt2 &key test key)

tries to comapre the data in two data-tables

Source

data-table.lisp.

Generic Function: data-table-value (dt &key col-name col-idx row-idx row)
Package

data-table.

Methods
Method: data-table-value ((dt data-table) &key col-name col-idx row-idx row)

Extract a value or set of values from the data table
can be used to pull a column of data, a row of data or a specific cell of data

Source

data-table.lisp.

Generic Function: (setf data-table-value) (dt &key col-name row-idx col-idx)
Package

data-table.

Methods
Method: (setf data-table-value) ((dt data-table) &key col-name row-idx col-idx)

Set a specific row, column or cell of the data table

Source

data-table.lisp.

Generic Function: fill-in-missing-cells (dt &optional missing-value)
Package

data-table.

Methods
Method: fill-in-missing-cells ((dt data-table) &optional missing-value)

Ensures that the data table is square and that every column has the same number of rows and every row has the same number of columns, filling in nil to accomplish this

Source

data-table.lisp.

Generic Function: make-sub-table (parent &key lci uci lri uri)
Package

data-table.

Methods
Method: make-sub-table (parent &key lci uci lri uri)

Make a new data table from a subset of another data-table
lci - low column index
uci - upper column index (as per subseq 1 beyond the col you want) lri - low row index
uri - upper row index (as per subseq 1 beyond the row you want)

Source

data-table.lisp.

Generic Function: number-of-columns (dt)
Package

data-table.

Methods
Method: number-of-columns ((dt data-table))
Source

data-table.lisp.

Generic Function: number-of-rows (dt)
Package

data-table.

Methods
Method: number-of-rows ((dt data-table))
Source

data-table.lisp.

Generic Function: overlay-region (new dt &key row-idx col-idx)
Package

data-table.

Methods
Method: overlay-region ((new data-table) (dt data-table) &key row-idx col-idx)

puts all values from new-dt into dt starting at row-idx col-idx

Source

data-table.lisp.

Generic Reader: rows (object)
Package

data-table.

Methods
Reader Method: rows ((data-table data-table))

automatically generated reader method

Source

data-table.lisp.

Target Slot

rows.

Generic Writer: (setf rows) (object)
Package

data-table.

Methods
Writer Method: (setf rows) ((data-table data-table))

automatically generated writer method

Source

data-table.lisp.

Target Slot

rows.

Generic Function: symbolize-column-names (dt)
Package

data-table.

Methods
Method: symbolize-column-names ((dt data-table))

Turn the column names of the data table into lisp symbols

Source

data-table.lisp.

Generic Function: symbolize-column-names! (dt)
Package

data-table.

Methods
Method: symbolize-column-names! ((dt data-table))

Turn the column names of the data table into lisp symbols save the new column names to the data table

Source

data-table.lisp.


5.1.4 Standalone methods

Method: print-object ((o bad-type-guess) s)
Source

data-table.lisp.


5.1.5 Conditions

Condition: bad-type-guess
Package

data-table.

Source

data-table.lisp.

Direct superclasses

error.

Direct methods
Direct slots
Slot: expected-type
Initargs

:expected-type

Readers

expected-type.

Writers

This slot is read-only.

Slot: original-error
Initargs

:original-error

Readers

original-error.

Writers

This slot is read-only.

Slot: value
Initargs

:value

Readers

value.

Writers

This slot is read-only.


Previous: , Up: Public Interface   [Contents][Index]

5.1.6 Classes

Class: data-table

A class representing a table of data

Package

data-table.

Source

data-table.lisp.

Direct methods
Direct slots
Slot: column-names
Initargs

:column-names

Readers

column-names.

Writers

(setf column-names).

Slot: column-types
Initargs

:column-types

Readers

column-types.

Writers

(setf column-types).

Slot: rows
Initargs

:rows

Readers

rows.

Writers

(setf rows).


5.2 Internals


Next: , Previous: , Up: Internals   [Contents][Index]

5.2.1 Special variables

Special Variable: *list-delimiter*

What we will splice lists together with in coerce-value-for-output

Package

data-table.

Source

data-table.lisp.

Special Variable: +common-white-space-trimbag+
Package

data-table.

Source

data-table.lisp.

Special Variable: +largest-number+

this is the largest number that will be considered a number for data-type purposes.

Package

data-table.

Source

data-table.lisp.


5.2.2 Ordinary functions

Function: %add-column-heading/type (dt name type index)

this function tries to handle their not being any current column types or names or incomplete specification but will leave us with the same (+ 1 number-of-columns) as we started with

Package

data-table.

Source

data-table.lisp.

Function: %insert-value-in-list (row index value)

build a new data row by splicing a value into the existing row

Package

data-table.

Source

data-table.lisp.

Function: alist-keys (al)
Package

data-table.

Source

data-table.lisp.

Function: alist-values (al &optional keys test)
Package

data-table.

Source

data-table.lisp.

Function: ensure-column-data-types (dt)

Given missing data types or data-types only of strings, figure out
what the data-types for the table should be set the slot on the data-table

Package

data-table.

Source

data-table.lisp.

Function: guess-types-for-data-table (data-table)
Package

data-table.

Source

data-table.lisp.

Function: maybe-apply (fn &rest args)

Call a function, when it exists
used to avoid calling clsql code if it does not exits

Package

data-table.

Source

data-table.lisp.

Function: plist-keys (pl)
Package

data-table.

Source

data-table.lisp.

Function: plist-values (pl &optional keys)
Package

data-table.

Source

data-table.lisp.

Function: sample-rows (rows &key sample-size)

get a subset of the rows using reservior sampling

Package

data-table.

Source

data-table.lisp.

Function: simplify-types (val)

try to get simple type definitions from complex ones

Package

data-table.

Source

data-table.lisp.

Function: transpose-lists (list-of-lists)

Transpose a matrix represented as a list of lists.
Example: (transpose ’((a b c) (d e f))) => ((a d) (b e) (c f)).

Package

data-table.

Source

data-table.lisp.

Function: trim-and-nullify (s)

trims the whitespace from a string returning nil
if trimming produces an empty string or the string ’nil’

Package

data-table.

Source

data-table.lisp.

Function: trim-whitespace (s)
Package

data-table.

Source

data-table.lisp.


5.2.3 Generic functions

Generic Function: data-table-coerce (d type)
Package

data-table.

Methods
Method: data-table-coerce (d type)
Source

data-table.lisp.

Generic Reader: expected-type (condition)
Package

data-table.

Methods
Reader Method: expected-type ((condition bad-type-guess))
Source

data-table.lisp.

Target Slot

expected-type.

Generic Reader: original-error (condition)
Package

data-table.

Methods
Reader Method: original-error ((condition bad-type-guess))
Source

data-table.lisp.

Target Slot

original-error.

Generic Function: relaxed-parse-float (str &key type)
Package

data-table.

Methods
Method: relaxed-parse-float (str &key type)

trys to read a value we hope to be a floating point number returns nil on failure

The goal is to allow reading strings with spaces commas and dollar signs in them correctly

Source

data-table.lisp.

Generic Reader: value (condition)
Package

data-table.

Methods
Reader Method: value ((condition bad-type-guess))
Source

data-table.lisp.

Target Slot

value.


Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts


Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   %   (  
A   C   D   E   F   G   M   N   O   P   R   S   T   V  
Index Entry  Section

%
%add-column-heading/type: Private ordinary functions
%insert-value-in-list: Private ordinary functions

(
(setf column-name): Public ordinary functions
(setf column-names): Public generic functions
(setf column-names): Public generic functions
(setf column-type): Public ordinary functions
(setf column-types): Public generic functions
(setf column-types): Public generic functions
(setf data-table-value): Public generic functions
(setf data-table-value): Public generic functions
(setf rows): Public generic functions
(setf rows): Public generic functions

A
add-column: Public ordinary functions
alist-keys: Private ordinary functions
alist-values: Private ordinary functions
alists-to-data-table: Public ordinary functions

C
coerce-data-table-of-strings-to-types: Public ordinary functions
coerce-data-table-values-for-output: Public ordinary functions
coerce-data-table-values-for-output!: Public ordinary functions
coerce-value-for-output: Public generic functions
coerce-value-for-output: Public generic functions
column-index: Public ordinary functions
column-name: Public ordinary functions
column-names: Public generic functions
column-names: Public generic functions
column-type: Public ordinary functions
column-types: Public generic functions
column-types: Public generic functions

D
data-table-coerce: Private generic functions
data-table-coerce: Private generic functions
data-table-data-compare: Public generic functions
data-table-data-compare: Public generic functions
data-table-to-alists: Public ordinary functions
data-table-to-plists: Public ordinary functions
data-table-value: Public generic functions
data-table-value: Public generic functions

E
ensure-column-data-types: Private ordinary functions
expected-type: Private generic functions
expected-type: Private generic functions

F
fill-in-missing-cells: Public generic functions
fill-in-missing-cells: Public generic functions
Function, %add-column-heading/type: Private ordinary functions
Function, %insert-value-in-list: Private ordinary functions
Function, (setf column-name): Public ordinary functions
Function, (setf column-type): Public ordinary functions
Function, add-column: Public ordinary functions
Function, alist-keys: Private ordinary functions
Function, alist-values: Private ordinary functions
Function, alists-to-data-table: Public ordinary functions
Function, coerce-data-table-of-strings-to-types: Public ordinary functions
Function, coerce-data-table-values-for-output: Public ordinary functions
Function, coerce-data-table-values-for-output!: Public ordinary functions
Function, column-index: Public ordinary functions
Function, column-name: Public ordinary functions
Function, column-type: Public ordinary functions
Function, data-table-to-alists: Public ordinary functions
Function, data-table-to-plists: Public ordinary functions
Function, ensure-column-data-types: Private ordinary functions
Function, guess-types-for-data-table: Private ordinary functions
Function, maybe-apply: Private ordinary functions
Function, plist-keys: Private ordinary functions
Function, plist-values: Private ordinary functions
Function, plists-to-data-table: Public ordinary functions
Function, sample-rows: Private ordinary functions
Function, select-columns: Public ordinary functions
Function, simplify-types: Private ordinary functions
Function, transpose-lists: Private ordinary functions
Function, trim-and-nullify: Private ordinary functions
Function, trim-whitespace: Private ordinary functions

G
Generic Function, (setf column-names): Public generic functions
Generic Function, (setf column-types): Public generic functions
Generic Function, (setf data-table-value): Public generic functions
Generic Function, (setf rows): Public generic functions
Generic Function, coerce-value-for-output: Public generic functions
Generic Function, column-names: Public generic functions
Generic Function, column-types: Public generic functions
Generic Function, data-table-coerce: Private generic functions
Generic Function, data-table-data-compare: Public generic functions
Generic Function, data-table-value: Public generic functions
Generic Function, expected-type: Private generic functions
Generic Function, fill-in-missing-cells: Public generic functions
Generic Function, make-sub-table: Public generic functions
Generic Function, number-of-columns: Public generic functions
Generic Function, number-of-rows: Public generic functions
Generic Function, original-error: Private generic functions
Generic Function, overlay-region: Public generic functions
Generic Function, relaxed-parse-float: Private generic functions
Generic Function, rows: Public generic functions
Generic Function, symbolize-column-names: Public generic functions
Generic Function, symbolize-column-names!: Public generic functions
Generic Function, value: Private generic functions
guess-types-for-data-table: Private ordinary functions

M
make-sub-table: Public generic functions
make-sub-table: Public generic functions
maybe-apply: Private ordinary functions
Method, (setf column-names): Public generic functions
Method, (setf column-types): Public generic functions
Method, (setf data-table-value): Public generic functions
Method, (setf rows): Public generic functions
Method, coerce-value-for-output: Public generic functions
Method, column-names: Public generic functions
Method, column-types: Public generic functions
Method, data-table-coerce: Private generic functions
Method, data-table-data-compare: Public generic functions
Method, data-table-value: Public generic functions
Method, expected-type: Private generic functions
Method, fill-in-missing-cells: Public generic functions
Method, make-sub-table: Public generic functions
Method, number-of-columns: Public generic functions
Method, number-of-rows: Public generic functions
Method, original-error: Private generic functions
Method, overlay-region: Public generic functions
Method, print-object: Public standalone methods
Method, relaxed-parse-float: Private generic functions
Method, rows: Public generic functions
Method, symbolize-column-names: Public generic functions
Method, symbolize-column-names!: Public generic functions
Method, value: Private generic functions

N
number-of-columns: Public generic functions
number-of-columns: Public generic functions
number-of-rows: Public generic functions
number-of-rows: Public generic functions

O
original-error: Private generic functions
original-error: Private generic functions
overlay-region: Public generic functions
overlay-region: Public generic functions

P
plist-keys: Private ordinary functions
plist-values: Private ordinary functions
plists-to-data-table: Public ordinary functions
print-object: Public standalone methods

R
relaxed-parse-float: Private generic functions
relaxed-parse-float: Private generic functions
rows: Public generic functions
rows: Public generic functions

S
sample-rows: Private ordinary functions
select-columns: Public ordinary functions
simplify-types: Private ordinary functions
symbolize-column-names: Public generic functions
symbolize-column-names: Public generic functions
symbolize-column-names!: Public generic functions
symbolize-column-names!: Public generic functions

T
transpose-lists: Private ordinary functions
trim-and-nullify: Private ordinary functions
trim-whitespace: Private ordinary functions

V
value: Private generic functions
value: Private generic functions

Jump to:   %   (  
A   C   D   E   F   G   M   N   O   P   R   S   T   V