The Data Frame I/O Reference Manual

The Data Frame I/O Reference Manual

This is the Data Frame I/O Reference Manual, version 1.0.0, generated automatically by Declt version 4.0b2.

Copyright © 2019-2022 Steve Nunez

Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies.

Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided also that the section entitled “Copying” is included exactly as in the original.

Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions, except that this permission notice may be translated as well.

Table of Contents


Copying

This program is distributed under the terms of the Microsoft Public License.


1 Systems

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


1.1 dfio

Common Lisp library for reading and writing data-frames

Long Name

Data frame I/O

Author

Steve Nunez <steve@symbolics.tech>

Source Control

(GIT https://github.com/Lisp-Stat/dfio.git)

Bug Tracker

https://github.com/Lisp-Stat/dfio/issues

License

MS-PL

Long Description

DFIO is used to read and write data frames from string, streams or disk. When building a library like this, one question that needs to be answered is "where do you draw the line on formats?". For example, should DFIO read/write JSON? The answer to that question is ’no’, and the reason is that there are many JSON formats – they are applicaton specific. Application specific format should be read in an application specific package, and this is the case, for example, with Vega. Formats like CSV, HD5 or Feather are application agnostic and should be included in DFIO.

Version

1.0.0

Dependencies
  • alexandria (system).
  • anaphora (system).
  • data-frame (system).
  • dexador (system).
  • fare-csv (system).
  • let-plus (system).
Source

dfio.asd.

Child Components

2 Files

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


2.1 Lisp


2.1.1 dfio/dfio.asd

Source

dfio.asd.

Parent Component

dfio (system).

ASDF Systems

dfio.


2.1.2 dfio/pkgdcl.lisp

Source

dfio.asd.

Parent Component

dfio (system).

Packages

2.1.3 dfio/decimal.lisp

Dependency

pkgdcl.lisp (file).

Source

dfio.asd.

Parent Component

dfio (system).

Public Interface
Internals

2.1.4 dfio/string-table.lisp

Dependency

decimal.lisp (file).

Source

dfio.asd.

Parent Component

dfio (system).

Public Interface
Internals

2.1.5 dfio/data-column.lisp

Dependency

string-table.lisp (file).

Source

dfio.asd.

Parent Component

dfio (system).

Public Interface
Internals

non-negative-integer (type).


2.1.6 dfio/utils.lisp

Dependency

data-column.lisp (file).

Source

dfio.asd.

Parent Component

dfio (system).

Public Interface
Internals

2.1.7 dfio/write.lisp

Dependency

utils.lisp (file).

Source

dfio.asd.

Parent Component

dfio (system).

Public Interface

2.1.8 dfio/delimited-text.lisp

Dependency

write.lisp (file).

Source

dfio.asd.

Parent Component

dfio (system).

Public Interface
Internals

csv-to-data-columns (function).


3 Packages

Packages are listed by definition order.


3.1 dfio.decimal

Source

pkgdcl.lisp.

Use List
  • anaphora.
  • common-lisp.
  • let-plus.
Used By List

dfio.data-column.

Public Interface
Internals

3.2 dfio.string-table

Source

pkgdcl.lisp.

Use List
  • alexandria.
  • anaphora.
  • common-lisp.
  • let-plus.
Used By List

dfio.data-column.

Public Interface
Internals

3.3 dfio

Source

pkgdcl.lisp.

Use List
Used By List

lisp-stat.

Public Interface
Internals

3.4 dfio.data-column

Source

pkgdcl.lisp.

Use List
Used By List

dfio.

Public Interface
Internals

non-negative-integer (type).


4 Definitions

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


4.1 Public Interface


4.1.1 Ordinary functions

Function: data-column (&key map-alist default-float-format)
Package

dfio.data-column.

Source

data-column.lisp.

Function: data-column-add (data-column string)
Package

dfio.data-column.

Source

data-column.lisp.

Function: data-column-counts (data-column)

Return the counts.

Package

dfio.data-column.

Source

data-column.lisp.

Function: data-column-vector (data-column)

Return the collected elements as a vector.

Package

dfio.data-column.

Source

data-column.lisp.

Function: parse-rational (string &key start end exponent-chars)

Parse a decimal rational in (subseq string start end) of the form [sign][whole][.[fraction]][exponent] where

sign ::= + | - | empty
whole ::= digit*
fraction ::= digit*
exponent ::= exponent-char[sign]digit+

with the restriction that WHOLE and FRACTION cannot be empty at the same time. EXPONENT-CHAR is a string and contains the valid exponent chars.

Whitespace is NOT trimmed, and leads to an error. In case of a parsing failure, PARSE-RATIONAL-ERROR is used.

Return (values NUMBER DECIMAL-DOT? EXPONENT-CHAR). NUMBER is a RATIONAL, DECIMAL-DOT? is T when a decimal dot is present, otherwise NIL, EXPONENT-CHAR contains the exponent character, NIL if not present.

Numbers of the form .112 and 112. are valid syntax, representing 0.112 and 112.0, respectively.

Examples:

(parse-rational "7") => (values 7 NIL NIL)
(parse-rational "7.") => (values 7 T NIL)
(parse-rational "0.7") => (values 7/10 T NIL)
(parse-rational ".7") => (values 7/10 T NIL)
(parse-rational "7.e2") => (values 700 T #e)
(parse-rational ".7d1") => (values 7 T #d)

Package

dfio.decimal.

Source

decimal.lisp.

Function: parse-real (string &key start end s-float f-float d-float l-float e-float)

Wrapper for PARSE-RATIONAL, converting non-integers to floats. The float type is determined by the -float arguments for each exponent character. Integers are not converted to floats. Return a single value, type of (or integer float).

See PARSE-RATIONAL for accepted formats, errors, etc.

Package

dfio.decimal.

Source

decimal.lisp.

Function: read-csv (source &key skip-first-row? column-keys-or-function package map-alist)

Read a CSV file, stream, string or URL into a DATA-FRAME, which is returned.
When SKIP-FIRST-ROW?, the first row is read separately and COLUMN-KEYS-OR-FUNCTION is used to form column keys.
When COLUMN-KEYS-OR-FUNCTION is a sequence, it is used for column keys, regardless of the value of SKIP-FIRST-ROW?.
PACKAGE indicates the package to intern column names into.

MAP-ALIST maps values during the import. This is useful if you want special mappings for missing, though the mechanism is general. Returns two values, the data-frame and the source

Package

dfio.

Source

delimited-text.lisp.

Function: save (data-symbol pathspec &optional suffix)

Save DF in the file named by PATHSPEC. By default, a suffix of .lisp is added.

Package

dfio.

Source

write.lisp.

Function: string-table (&key table)
Package

dfio.string-table.

Source

string-table.lisp.

Function: string-table-add (string-table string &optional value)

Add STRING mapped to VALUE to STRING-TABLE, raising STRING-TABLE-DUPLICATE if STRING is already in the table. Return VALUE.

Package

dfio.string-table.

Source

string-table.lisp.

Function: string-table-count (string-table)

Number of distinct strings in the table.

Package

dfio.string-table.

Source

string-table.lisp.

Function: string-table-intern (string-table string &optional new-value)

If STRING is already in STRING-TABLE, return its value, otherwise add it and return NEW-VALUE. When used with the default argument for NEW-VALUE, EQUAL strings are always mapped to values that are EQ.

Package

dfio.string-table.

Source

string-table.lisp.

Function: string-table-lookup (string-table string)

Return the value corresponding to STRING in STRING-TABLE, or raise the STRING-TABLE-NOT-FOUND error.

Package

dfio.string-table.

Source

string-table.lisp.

Function: string-table-strings (string-table)

List of strings in STRING-TABLE.

Package

dfio.string-table.

Source

string-table.lisp.

Function: string-to-keyword (string)

Map string to a keyword.

The current implementation replaces #. and #space with a #-, and upcases all other characters.

Package

dfio.

Source

utils.lisp.

Function: string-to-symbol (string)

Map STRING to a symbol in PACKAGE, replacing #., #_ and #space with a #-, and upcasing all other characters. Exports symbol.

Package

dfio.

Source

utils.lisp.

Function: symbol-name-to-pathname (string)

Map the symbol-name of S to something that can be part of a logical-pathname

Package

dfio.

Source

utils.lisp.

Function: write-csv (df stream &key add-first-row separator quote eol)

Write DF to STRING-OR-STREAM in CSV format. STRING-OR-STREAM can be a STREAM, a STRING or a file PATHSPEC.

Keywords:
string-or-stream: stream to write to. Default: nil, returning a string
add-first-row: add column names as the first row
separator: separator to use when reading or writing CSV files. A character. By default, a comma: #,
quote: quote character to use when reading or writing CSV files. A character. By default, a double-quote: #" eol: line ending to use when writing CSV files. A string. By default, +CRLF+ as specified by creativyst.

Notes:
The :newline keyword requires a sequence, so use :newline ’(#newline)

Package

dfio.

Source

delimited-text.lisp.

Function: write-df (data-symbol &optional stream)

Write DATA-SYMBOL to STREAM in a format suitable for reading back in with the Lisp reader

Package

dfio.

Source

write.lisp.

Function: write-properties (data-symbol property &optional stream)

Write the variable PROPERTY strings to stream so they can be read back in when LOADed from a lisp file. By convention, the name of the function that sets the property is the same as the property. Example (write-property mtcars :label)

Package

dfio.

Source

write.lisp.


4.1.2 Standalone methods

Method: print-object ((string-table string-table) stream)
Source

string-table.lisp.


4.1.3 Conditions

Condition: parse-rational-error

Error used by parse-rational and parse-real.

Package

dfio.decimal.

Source

decimal.lisp.

Direct superclasses

error.

Direct slots
Slot: string
Package

common-lisp.

Initform

(quote nil)

Initargs

:string

Slot: message
Initform

(quote nil)

Initargs

:message

Condition: string-table-duplicate

String is already in the table.

Package

dfio.string-table.

Source

string-table.lisp.

Direct superclasses

error.

Condition: string-table-not-found

String not found in table.

Package

dfio.string-table.

Source

string-table.lisp.

Direct superclasses

error.


4.1.4 Structures

Structure: string-table

A table of distinct strings, optionally mapping each one to a value.

Package

dfio.string-table.

Source

string-table.lisp.

Direct superclasses

structure-object.

Direct methods

print-object.

Direct slots
Slot: table
Type

hash-table

Initform

(make-hash-table :test (function equalp))

Readers

string-table-table.

Writers

(setf string-table-table).


4.1.5 Classes

Class: data-column
Package

dfio.data-column.

Source

data-column.lisp.

Direct slots
Slot: reverse-elements
Type

list

Slot: default-float-format
Type

symbol

Initargs

:default-float-format

Slot: float-count
Type

dfio.data-column::non-negative-integer

Initform

0

Slot: integer-count
Type

dfio.data-column::non-negative-integer

Initform

0

Slot: integer-min
Type

integer

Initform

0

Slot: integer-max
Type

integer

Initform

0

Slot: map-count
Type

dfio.data-column::non-negative-integer

Initform

0

Slot: map-table
Type

dfio.string-table:string-table

Initargs

:map-table

Slot: string-count
Type

dfio.data-column::non-negative-integer

Initform

0

Slot: string-table
Package

dfio.string-table.

Type

dfio.string-table:string-table

Initform

(dfio.string-table:string-table)


4.2 Internals


4.2.1 Special variables

Special Variable: *default-external-format*

External format used for opening files

Package

dfio.

Source

utils.lisp.

Special Variable: +exponent-chars+

Default exponent characters.

Package

dfio.decimal.

Source

decimal.lisp.


4.2.2 Macros

Macro: with-csv-output-stream ((name inp) &body body)
Package

dfio.

Source

utils.lisp.

Macro: with-input-stream ((name inp) &body body)
Package

dfio.

Source

utils.lisp.


4.2.3 Ordinary functions

Function: %in-stream (source)
Package

dfio.

Source

utils.lisp.

Function: %out-stream (source)

creates a stream from the given thing, trying to DWIM

Package

dfio.

Source

utils.lisp.

Function: copy-string-table (instance)
Package

dfio.string-table.

Source

string-table.lisp.

Function: csv-to-data-columns (source skip-first-row? &key map-alist)

Read a CSV file (or stream, or string), accumulate the values in DATA-COLUMNs, return a list of these. Rows are checked to have the same number of elements.

When SKIP-FIRST-ROW?, the first row is read separately and returned as the second value (list of strings), otherwise it is considered data like all other rows.

Package

dfio.

Source

delimited-text.lisp.

Function: gobble-positive-integer (string start end)

If (SUBSEQ STRING START END) starts with a nonnegative integer (ie a sequence of digits 0-9), return the integer and position at which it ends as two values.

Otherwise, return NIL and 0.

START < END has to hold, END cannot be NIL. Consequences are undefined when START >= END.

Package

dfio.decimal.

Source

decimal.lisp.

Function: gobble-sign (string start)

Return (values SIGNUM INDEX), where SIGNUM is -1 or 1 depending on whether (CHAR STRING START) was a sign, and INDEX is the index of the subsequent character (START or START+1).

Package

dfio.decimal.

Source

decimal.lisp.

Function: string-table-get (string-table string)

Synonym for GETHASH, used internally.

Package

dfio.string-table.

Source

string-table.lisp.

Function: (setf string-table-get) (string-table string)

Synonym for (SETF GETHASH), used internally, checks that STRING is a string.

Package

dfio.string-table.

Source

string-table.lisp.

Function: string-table-p (object)
Package

dfio.string-table.

Source

string-table.lisp.

Reader: string-table-table (instance)
Writer: (setf string-table-table) (instance)
Package

dfio.string-table.

Source

string-table.lisp.

Target Slot

table.


4.2.4 Types

Type: non-negative-integer ()
Package

dfio.data-column.

Source

data-column.lisp.

Type: str-strm-file ()
Package

dfio.

Source

utils.lisp.


Appendix A Indexes


A.1 Concepts


A.2 Functions

Jump to:   %   (  
C   D   F   G   M   P   R   S   W  
Index Entry  Section

%
%in-stream: Private ordinary functions
%out-stream: Private ordinary functions

(
(setf string-table-get): Private ordinary functions
(setf string-table-table): Private ordinary functions

C
copy-string-table: Private ordinary functions
csv-to-data-columns: Private ordinary functions

D
data-column: Public ordinary functions
data-column-add: Public ordinary functions
data-column-counts: Public ordinary functions
data-column-vector: Public ordinary functions

F
Function, %in-stream: Private ordinary functions
Function, %out-stream: Private ordinary functions
Function, (setf string-table-get): Private ordinary functions
Function, (setf string-table-table): Private ordinary functions
Function, copy-string-table: Private ordinary functions
Function, csv-to-data-columns: Private ordinary functions
Function, data-column: Public ordinary functions
Function, data-column-add: Public ordinary functions
Function, data-column-counts: Public ordinary functions
Function, data-column-vector: Public ordinary functions
Function, gobble-positive-integer: Private ordinary functions
Function, gobble-sign: Private ordinary functions
Function, parse-rational: Public ordinary functions
Function, parse-real: Public ordinary functions
Function, read-csv: Public ordinary functions
Function, save: Public ordinary functions
Function, string-table: Public ordinary functions
Function, string-table-add: Public ordinary functions
Function, string-table-count: Public ordinary functions
Function, string-table-get: Private ordinary functions
Function, string-table-intern: Public ordinary functions
Function, string-table-lookup: Public ordinary functions
Function, string-table-p: Private ordinary functions
Function, string-table-strings: Public ordinary functions
Function, string-table-table: Private ordinary functions
Function, string-to-keyword: Public ordinary functions
Function, string-to-symbol: Public ordinary functions
Function, symbol-name-to-pathname: Public ordinary functions
Function, write-csv: Public ordinary functions
Function, write-df: Public ordinary functions
Function, write-properties: Public ordinary functions

G
gobble-positive-integer: Private ordinary functions
gobble-sign: Private ordinary functions

M
Macro, with-csv-output-stream: Private macros
Macro, with-input-stream: Private macros
Method, print-object: Public standalone methods

P
parse-rational: Public ordinary functions
parse-real: Public ordinary functions
print-object: Public standalone methods

R
read-csv: Public ordinary functions

S
save: Public ordinary functions
string-table: Public ordinary functions
string-table-add: Public ordinary functions
string-table-count: Public ordinary functions
string-table-get: Private ordinary functions
string-table-intern: Public ordinary functions
string-table-lookup: Public ordinary functions
string-table-p: Private ordinary functions
string-table-strings: Public ordinary functions
string-table-table: Private ordinary functions
string-to-keyword: Public ordinary functions
string-to-symbol: Public ordinary functions
symbol-name-to-pathname: Public ordinary functions

W
with-csv-output-stream: Private macros
with-input-stream: Private macros
write-csv: Public ordinary functions
write-df: Public ordinary functions
write-properties: Public ordinary functions

Jump to:   %   (  
C   D   F   G   M   P   R   S   W  

A.4 Data types

Jump to:   C   D   F   N   P   S   T   U   W  
Index Entry  Section

C
Class, data-column: Public classes
Condition, parse-rational-error: Public conditions
Condition, string-table-duplicate: Public conditions
Condition, string-table-not-found: Public conditions

D
data-column: Public classes
data-column.lisp: The dfio/data-column․lisp file
decimal.lisp: The dfio/decimal․lisp file
delimited-text.lisp: The dfio/delimited-text․lisp file
dfio: The dfio system
dfio: The dfio package
dfio.asd: The dfio/dfio․asd file
dfio.data-column: The dfio․data-column package
dfio.decimal: The dfio․decimal package
dfio.string-table: The dfio․string-table package

F
File, data-column.lisp: The dfio/data-column․lisp file
File, decimal.lisp: The dfio/decimal․lisp file
File, delimited-text.lisp: The dfio/delimited-text․lisp file
File, dfio.asd: The dfio/dfio․asd file
File, pkgdcl.lisp: The dfio/pkgdcl․lisp file
File, string-table.lisp: The dfio/string-table․lisp file
File, utils.lisp: The dfio/utils․lisp file
File, write.lisp: The dfio/write․lisp file

N
non-negative-integer: Private types

P
Package, dfio: The dfio package
Package, dfio.data-column: The dfio․data-column package
Package, dfio.decimal: The dfio․decimal package
Package, dfio.string-table: The dfio․string-table package
parse-rational-error: Public conditions
pkgdcl.lisp: The dfio/pkgdcl․lisp file

S
str-strm-file: Private types
string-table: Public structures
string-table-duplicate: Public conditions
string-table-not-found: Public conditions
string-table.lisp: The dfio/string-table․lisp file
Structure, string-table: Public structures
System, dfio: The dfio system

T
Type, non-negative-integer: Private types
Type, str-strm-file: Private types

U
utils.lisp: The dfio/utils․lisp file

W
write.lisp: The dfio/write․lisp file

Jump to:   C   D   F   N   P   S   T   U   W