File: DOCUMENTATION.md

package info (click to toggle)
cl-csv 20180712.git3eba29c-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 244 kB
  • sloc: lisp: 1,765; makefile: 2
file content (211 lines) | stat: -rw-r--r-- 5,162 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
	CL-CSV - a Common Lisp library for csv reading and writing
=====

# Abstract

A common lisp library providing easy csv reading and writing.

The code license is found
[here](https://github.com/AccelerationNet/cl-csv/blob/master/LICENSE).


# Contents

1.  [Download](#download)
2.  [The CL-CSV dictionary](#dictionary)
   1.  [`*default-external-format*`](#*default-external-format*)
   2.  [`*newline*`](#*newline*)
   3.  [`*quote*`](#*quote*)
   4.  [`*quote-escape*`](#*quote-escape*)
   5.  [`*separator*`](#*separator*)
   6.  [`csv-parse-error`](#csv-parse-error)
   7.  [`csv-parse-error`](#csv-parse-error)
   8.  [`do-csv`](#do-csv)
   9.  [`format-csv-value`](#format-csv-value)
   10. [`read-csv`](#read-csv)
   11. [`read-csv-row`](#read-csv-row)
   12. [`write-csv`](#write-csv)
   13. [`write-csv-row`](#write-csv-row)
   14. [`write-csv-value`](#write-csv-value)

3.  [Acknowledgements](#ack)



# Download

CL-CSV together with this documentation can be downloaded from
[https://github.com/AccelerationNet/cl-csv](https://github.com/AccelerationNet/cl-csv).

# The CL-CSV dictionary

_[Special variable]_
**\*default-external-format***

The external format used for opening files

_[Special variable]_
**\*newline***

 Default newline string

_[Special variable]_
**\*quote***

 Default quote character

_[Special variable]_
**\*quote-escape***

 Default setting for escaping quotes

_[Special variable]_
**\*separator***

 Default separator character

- - -
_[Condition type]_
**csv-parse-error**
- - -
_[Function]_
**csv-parse-error** ( *msg `&rest` args* ) =\> \*result*
- - -
_[Macro]_
**do-csv** *((row-var stream-or-pathname `&rest` read-csv-keys)
`&body` body)* =\> \*result*


row-var: a variable that is passed into _body_

stream-or-pathname: a stream or a pathname to read the CSV data from

read-csv-keys: keys and values passed to the _read-csv_ function

body: body of the macro

- - -
_[Generic function]_
**format-csv-value** ( *val* ) =\> \*result*

- - -
_[Method]_
**format-csv-value** ( *val* ) =\> \*result*

 Print values in ways that are most cross compatible with the csv
format
- - -
_[Function]_
**read-csv** ( *stream-or-string* `&key` *row-fn* *map-fn* *sample*
*skip-first-p* ( separator \*separator\* ) (quote \*quote\*) (escape
\*quote-escape\*))* =\> \*result*

Read in a CSV by data-row (which due to quoted newlines may be more
than one line from the stream)

row-fn: passing this parameter will cause this read to be streaming
and results will be discarded after the row-fn is called with data

map-fn: used for manipulating the data by row during collection if
specified; (funcall map-fn data) is collected instead of data

sample: when a positive integer, only take that many samples from
the input file

skip-first-p: when true, skips the first line in the csv

_Keywords:_

separator: character separating between data cells. Defaults to
\*separator*

quote: quoting character for text strings. Defaults to \*quote*

escape: escape character. Defaults to \*quote-escape*

- - -
_[Function]_
**read-csv-row** ( *stream-or-string* `&key` (separator \*separator\*)
(quote \*quote\*) (escape \*quote-escape\*) `&aux` *current state line
llen c elen*) =\> \*result\*


Read in a CSV by _data-row_ (which due to quoted newlines may be more
than one line from the stream)

- - -
_[Function]_
**write-csv** (*rows-of-items* `&key` *stream* (separator \*separator\*)
(quote \*quote\*) (escape \*quote-escape\*) (newline \*newline\*)
(always-quote \*always-quote\*) ) =\> \*result\*

Writes a CSV

rows-of-items: iterable

_Keywords:_

stream: stream to write to. Default: nil.

quote: quoting character. Defaults to \*quote\*

escape: escaping character. Defaults to \*quote-escape\*

newline: newline character. Defaults to \*newline\*

always-quote: Defaults to \*always-quote\*

- - -
_[Function]_
**write-csv-row** ( *items* `&key` *stream* (separator \*separator\*)
(quote \*quote\*) (escape \*quote-escape\*) (newline \*newline\*)
(always-quote \*always-quote\*) ) =\> \*result*


Writes a list items to stream

rows-of-items: iterable

_Keywords:_

stream: stream to write to. Default: nil.

quote: quoting character. Defaults to \*quote\*

escape: escaping character. Defaults to \*quote-escape\*

newline: newline character. Defaults to \*newline\*

always-quote: Defaults to \*always-quote\*

- - -
_[Generic function]_
**write-csv-value** ( *val csv-stream* `&key` *formatter quote separator
escape always-quote* ) =\> \*result*

- - -
_[Method]_
**write-csv-value** ( *val csv-stream* `&key` *formatter quote separator
escape always-quote* ) =\> \*result*


Writes val to csv-stream in a formatted fashion.

_Keywords:_

formatter: used to format val. Defaults to format-csv-value.

quote: quoting character. Defaults to \*quote*

escape: escaping character. Defaults to \*quote-escape*

newline: newline character. Defaults to \*newline*

always-quote: Defaults to \*always-quote*

# Acknowledgements

This documentation was prepared with
[DOCUMENTATION-TEMPLATE](http://weitz.de/documentation-template/),
then passed through
[pandoc](http://johnmacfarlane.net/pandoc/index.html), *then* hand-edited.