The csv-parser Reference Manual

This is the csv-parser Reference Manual, generated automatically by Declt version 4.0 beta 2 "William Riker" on Sun Sep 15 04:55:09 2024 GMT+0.

Table of Contents


1 Introduction


2 Systems

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


2.1 csv-parser

CSV parsing/writing utilities, a la Microsoft Excel

Author

Alain Picard <>

License

LLGPL

Source

csv-parser.asd.

Child Component

csv-parser.lisp (file).


3 Files

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


3.1 Lisp


3.1.1 csv-parser/csv-parser.asd

Source

csv-parser.asd.

Parent Component

csv-parser (system).

ASDF Systems

csv-parser.


3.1.2 csv-parser/csv-parser.lisp

Source

csv-parser.asd.

Parent Component

csv-parser (system).

Packages

csv-parser.

Public Interface
Internals

4 Packages

Packages are listed by definition order.


4.1 csv-parser

Source

csv-parser.lisp.

Use List

common-lisp.

Public Interface
Internals

5 Definitions

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


5.1 Public Interface


5.1.1 Special variables

Special Variable: *field-separator*

The character used to indicate the end of a field in a CSV file.

Package

csv-parser.

Source

csv-parser.lisp.

Special Variable: *quote-character*

The character used to protect embedded field separators (usually commas) and whitespace within a field.

To import the *quote-character* itself, you must have it printed twice in the input stream.

Package

csv-parser.

Source

csv-parser.lisp.


5.1.2 Macros

Macro: do-csv-file (((fields num-fields) file &key limit skip-lines external-format field-separator quote-character) &body body)

Repeatedly call BODY on CSV file FILE, binding
FIELDS and NUM-FIELDS to a list containing the parsed fields, and the number of fields.
Code runs inside a block with tagname NIL, so you
may call (RETURN).

*FIELD-SEPARATOR* and *QUOTE-CHARACTER* can be bound to modify what separates fields and delimits fields.

Package

csv-parser.

Source

csv-parser.lisp.


5.1.3 Ordinary functions

Function: map-csv-file (file fn &key limit skip-lines external-format field-separator quote-character)

Call FN (up to LIMIT times, if specified) with
a list containing the fields parsed from the CSV file FILE.

SKIP-LINES, if provided, is the number of lines to skip before starting to call FN.

*FIELD-SEPARATOR* and *QUOTE-CHARACTER* can be bound to modify what separates fields and delimits fields.

Package

csv-parser.

Source

csv-parser.lisp.

Function: read-csv-line (stream)

Read one line form a stream containing CSV data. Returns two values; a list of strings parsed, and the number of parsed values.

Package

csv-parser.

Source

csv-parser.lisp.

Function: write-csv-line (stream fields)

Write one CSV line to STREAM, containing fields.
FIELDS is any (1d) sequence containing strings, symbols or numbers.

Try to write it as esthetically pleasing as possible,
i.e. don’t output the *quote-character* unless necessary
to protect the integrity of the data.

Package

csv-parser.

Source

csv-parser.lisp.


5.2 Internals


5.2.1 Special variables

Special Variable: *current-field*

Holds the field we are currently working on.

Package

csv-parser.

Source

csv-parser.lisp.

Special Variable: *fields*

Holds the fields we have collected/parsed so far.

Package

csv-parser.

Source

csv-parser.lisp.

Special Variable: *num-fields*
Package

csv-parser.

Source

csv-parser.lisp.

Special Variable: *spaces-gobbled*

Keeps track of how many blanks have been skipped. When emitting
a field, we can trim extra right spaces, if appropriate, using this.

Package

csv-parser.

Source

csv-parser.lisp.

Special Variable: *state*

Holds a function which knows how to handle chars based on what we’ve seen so far.

Package

csv-parser.

Source

csv-parser.lisp.


5.2.2 Ordinary functions

Function: add-char (char)
Package

csv-parser.

Source

csv-parser.lisp.

Function: change-state (state)
Package

csv-parser.

Source

csv-parser.lisp.

Function: csv-test-blank ()
Package

csv-parser.

Source

csv-parser.lisp.

Function: csv-test-blanks ()
Package

csv-parser.

Source

csv-parser.lisp.

Function: csv-test-double-quotes ()
Package

csv-parser.

Source

csv-parser.lisp.

Function: csv-test-embedded-commas ()
Package

csv-parser.

Source

csv-parser.lisp.

Function: csv-test-embedded-lines ()
Package

csv-parser.

Source

csv-parser.lisp.

Function: csv-test-empty ()
Package

csv-parser.

Source

csv-parser.lisp.

Function: csv-test-empty-1 ()
Package

csv-parser.

Source

csv-parser.lisp.

Function: csv-test-other-delimiters ()
Package

csv-parser.

Source

csv-parser.lisp.

Function: csv-test-quoted ()
Package

csv-parser.

Source

csv-parser.lisp.

Function: csv-test-round-trip1 (row)
Package

csv-parser.

Source

csv-parser.lisp.

Function: csv-test-round-trips ()
Package

csv-parser.

Source

csv-parser.lisp.

Function: csv-test-simple ()
Package

csv-parser.

Source

csv-parser.lisp.

Function: csv-test-space-handling ()
Package

csv-parser.

Source

csv-parser.lisp.

Function: csv-tests ()
Package

csv-parser.

Source

csv-parser.lisp.

Function: emit-field ()
Package

csv-parser.

Source

csv-parser.lisp.

Function: end-of-field-char-p (char)
Package

csv-parser.

Source

csv-parser.lisp.

Function: end-of-line-char-p (char)
Package

csv-parser.

Source

csv-parser.lisp.

Function: got-first-quote (char)
Package

csv-parser.

Source

csv-parser.lisp.

Function: got-second-quote (char)
Package

csv-parser.

Source

csv-parser.lisp.

Function: make-empty-field ()
Package

csv-parser.

Source

csv-parser.lisp.

Function: quote-char-p (char)
Package

csv-parser.

Source

csv-parser.lisp.

Function: regular-field (char)
Package

csv-parser.

Source

csv-parser.lisp.

Function: remove-last-n-chars (n)
Package

csv-parser.

Source

csv-parser.lisp.

Function: skip-white-space (char)
Package

csv-parser.

Source

csv-parser.lisp.

Function: special-char-p (char)
Package

csv-parser.

Source

csv-parser.lisp.

Function: white-space-char-p (char)
Package

csv-parser.

Source

csv-parser.lisp.

Function: write-csv-field (stream field)
Package

csv-parser.

Source

csv-parser.lisp.

Function: write-csv-line-on-array (stream fields)
Package

csv-parser.

Source

csv-parser.lisp.

Function: write-csv-line-on-cons (stream fields)
Package

csv-parser.

Source

csv-parser.lisp.

Function: write-csv-string-safely (stream string)
Package

csv-parser.

Source

csv-parser.lisp.

Function: write-protected-copy (stream field)
Package

csv-parser.

Source

csv-parser.lisp.


Appendix A Indexes


A.1 Concepts


A.2 Functions

Jump to:   A   C   D   E   F   G   M   Q   R   S   W  
Index Entry  Section

A
add-char: Private ordinary functions

C
change-state: Private ordinary functions
csv-test-blank: Private ordinary functions
csv-test-blanks: Private ordinary functions
csv-test-double-quotes: Private ordinary functions
csv-test-embedded-commas: Private ordinary functions
csv-test-embedded-lines: Private ordinary functions
csv-test-empty: Private ordinary functions
csv-test-empty-1: Private ordinary functions
csv-test-other-delimiters: Private ordinary functions
csv-test-quoted: Private ordinary functions
csv-test-round-trip1: Private ordinary functions
csv-test-round-trips: Private ordinary functions
csv-test-simple: Private ordinary functions
csv-test-space-handling: Private ordinary functions
csv-tests: Private ordinary functions

D
do-csv-file: Public macros

E
emit-field: Private ordinary functions
end-of-field-char-p: Private ordinary functions
end-of-line-char-p: Private ordinary functions

F
Function, add-char: Private ordinary functions
Function, change-state: Private ordinary functions
Function, csv-test-blank: Private ordinary functions
Function, csv-test-blanks: Private ordinary functions
Function, csv-test-double-quotes: Private ordinary functions
Function, csv-test-embedded-commas: Private ordinary functions
Function, csv-test-embedded-lines: Private ordinary functions
Function, csv-test-empty: Private ordinary functions
Function, csv-test-empty-1: Private ordinary functions
Function, csv-test-other-delimiters: Private ordinary functions
Function, csv-test-quoted: Private ordinary functions
Function, csv-test-round-trip1: Private ordinary functions
Function, csv-test-round-trips: Private ordinary functions
Function, csv-test-simple: Private ordinary functions
Function, csv-test-space-handling: Private ordinary functions
Function, csv-tests: Private ordinary functions
Function, emit-field: Private ordinary functions
Function, end-of-field-char-p: Private ordinary functions
Function, end-of-line-char-p: Private ordinary functions
Function, got-first-quote: Private ordinary functions
Function, got-second-quote: Private ordinary functions
Function, make-empty-field: Private ordinary functions
Function, map-csv-file: Public ordinary functions
Function, quote-char-p: Private ordinary functions
Function, read-csv-line: Public ordinary functions
Function, regular-field: Private ordinary functions
Function, remove-last-n-chars: Private ordinary functions
Function, skip-white-space: Private ordinary functions
Function, special-char-p: Private ordinary functions
Function, white-space-char-p: Private ordinary functions
Function, write-csv-field: Private ordinary functions
Function, write-csv-line: Public ordinary functions
Function, write-csv-line-on-array: Private ordinary functions
Function, write-csv-line-on-cons: Private ordinary functions
Function, write-csv-string-safely: Private ordinary functions
Function, write-protected-copy: Private ordinary functions

G
got-first-quote: Private ordinary functions
got-second-quote: Private ordinary functions

M
Macro, do-csv-file: Public macros
make-empty-field: Private ordinary functions
map-csv-file: Public ordinary functions

Q
quote-char-p: Private ordinary functions

R
read-csv-line: Public ordinary functions
regular-field: Private ordinary functions
remove-last-n-chars: Private ordinary functions

S
skip-white-space: Private ordinary functions
special-char-p: Private ordinary functions

W
white-space-char-p: Private ordinary functions
write-csv-field: Private ordinary functions
write-csv-line: Public ordinary functions
write-csv-line-on-array: Private ordinary functions
write-csv-line-on-cons: Private ordinary functions
write-csv-string-safely: Private ordinary functions
write-protected-copy: Private ordinary functions