source: project/wiki/eggref/4/csv-xml @ 34888

Last change on this file since 34888 was 34888, checked in by Kon Lovett, 4 years ago

rel 0.12.0

File size: 4.7 KB
Line 
1[[tags: egg]]
2
3== csv-xml
4
5[[toc:]]
6
7
8== Documentation
9
10A CHICKEN version of "csv-scheme". Some additions/extensions to the original.
11
12=== Input
13
14See [[http://www.neilvandyke.org/csv-scheme/|csv-scheme]] for the full documentation.
15
16==== csv-reader?
17
18<procedure>(csv-reader? OBJECT) => boolean</procedure>
19
20Is the {{OBJECT}} a {{csv-reader}}?
21
22==== check-csv-reader
23
24<procedure>(check-csv-reader LOC OBJECT [ARG-NAME]) => csv-reader-procedure</procedure>
25
26==== error-csv-reader
27
28<procedure>(error-csv-reader LOC OBJECT [ARG-MESSAGE []])</procedure>
29
30==== reader-spec
31
32<procedure>(reader-spec [(NEWLINE-TYPE 'lax) (SEPARATOR-CHARS '(#\,)) (QUOTE-CHAR #\") (COMMENT-CHARS '()) (QUOTE-DOUBLING-ESCAPES? #t) (WHITESPACE-CHARS '(#\space)) (STRIP-LEADING-WHITESPACE? #f) (STRIP-TRAILING-WHITESPACE? #f) (NEWLINES-IN-QUOTES? #t)]) => csv-reader-spec</procedure>
33
34==== csv-reader-spec?
35
36<procedure>(csv-reader-spec? OBJECT) => boolean</procedure>
37
38Is the {{OBJECT}} a {{csv-reader-spec}}?
39
40==== check-csv-reader-spec
41
42<procedure>(check-csv-reader-spec LOC OBJECT [ARG-NAME]) => csv-reader-spec</procedure>
43
44==== error-csv-reader-spec
45
46<procedure>(error-csv-reader-spec LOC OBJECT [ARG-MESSAGE []])</procedure>
47
48
49=== Output
50
51==== make-csv-writer-maker
52
53<procedure>(make-csv-writer-maker [WRITER-SPEC]) =>  (#!optional csv-writer-spec -> ((or output-port string) -> (* -> undefined)))</procedure>
54
55See {{writer-spec}} below for the default {{WRITER-SPEC}}.
56
57==== make-csv-writer
58
59<procedure>(make-csv-writer OUT-OR-STR [WRITER-SPEC]) => (* -> undefined)</procedure>
60
61Returns a {{procedure}} of 1 argument, a {{scheme-object}}, the {{ROW-DATA-OBJECT}}.
62
63{{OUT-OR-STR}} is {{output-port}} or {{string}}. A {{string}} is interpreted
64as a {{pathname}} to yield an {{output-port}}.
65
66See {{writer-spec}} below for the default {{WRITER-SPEC}}.
67
68When the {{ROW-DATA-OBJECT}} is a {{list}} then it is interpreted as
69row data. Otherwise assumed to be a comment.
70
71The {{ROW-DATA-OBJECT}} argument will be converted to an output {{string}},
72according to the associated {{csv-writer-spec}}, and printed to the associated
73{{output-port}}.
74
75==== csv-writer?
76
77<procedure>(csv-writer? OBJECT) => boolean</procedure>
78
79Is the {{OBJECT}} a {{csv-writer}}?
80
81==== check-csv-writer
82
83<procedure>(check-csv-writer LOC OBJECT [ARG-NAME]) => csv-writer-procedure</procedure>
84
85==== error-csv-writer
86
87<procedure>(error-csv-writer LOC OBJECT [ARG-MESSAGE []])</procedure>
88
89==== writer-spec
90
91<procedure>(writer-spec [(NEWLINE-CHAR #t) (SEPARATOR-CHAR #\,) (QUOTE-CHAR #\") (COMMENT-CHAR #\#) (QUOTE-DOUBLING-ESCAPES? #t) (QUOTE-CONTROLS? #t) (ALWAYS-QUOTE? #t)]) => csv-writer-spec</procedure>
92
93{{NEWLINE-CHAR}} is {{#t}}, {{cr}}, {{lf}}, or {{crlf}}. {{#t}} is the platform default.
94
95{{COMMENT-CHAR}} is {{#f}}, or a {{character}}. {{#f}} means no comment support.
96{{#\#}} is the default.
97
98{{QUOTE-DOUBLING-ESCAPES?}} is a {{boolean}}, default is {{#t}}.
99
100{{QUOTE-CONTROLS?}} is a {{boolean}}, default is {{#t}}, quoting strings with iso-control characters?
101
102{{ALWAYS-QUOTE?}} is a {{boolean}}, default is {{#t}}.
103
104==== csv-writer-spec?
105
106<procedure>(csv-writer-spec? OBJECT) => boolean</procedure>
107
108Is the {{OBJECT}} a {{csv-writer-spec}}?
109
110==== check-csv-writer-spec
111
112<procedure>(check-csv-writer-spec LOC OBJECT [ARG-NAME]) => csv-writer-spec</procedure>
113
114==== error-csv-writer-spec
115
116<procedure>(error-csv-writer-spec LOC OBJECT [ARG-MESSAGE []])</procedure>
117
118==== list->csv
119
120<procedure>(list->csv LS [WRITER-OR-OUT])</procedure>
121
122{{LS}} is a {{list-of list | string}}, a list of row-item.
123
124{{WRITER-OR-OUT}} is a {{csv-writer}} or {{output-port}}. Default is the
125{{(current-output-port)}}. Note that when an {{output-port}} is specified the
126default {{csv-writer-spec}} will be used.
127
128When the current row-item is a {{string}}, and not a {{list}}, then it is
129treated as a line-comment. Note that comments are processed only when the
130associated {{csv-writer-spec}} {{comment-char}} is a {{character}}.
131
132<enscript language=scheme>
133;assumes string output & comment-char is #\#
134(list->csv '((1 22 333) "a comment" (11 2222 333333)))
135;=> "\"1\",\"22\",\"333\"\n#a comment\n\"11\",\"2222\",\"333333\"\n"
136</enscript>
137
138
139== Usage
140
141<enscript language=scheme>
142(require-extension csv-xml)
143</enscript>
144
145
146== Author
147
148Neil van Dyke
149
150[[kon lovett|Kon Lovett]] for CHICKEN
151
152
153== Bugs & Limitations
154
155* The {{quote-doubling-escapes?}} and {{quote-controls?}} are currently
156ignored by {{csv-writer}}.
157
158
159== Version history
160
161; 0.12.0 : Use {{quote-doubling-escapes?}} and {{quote-controls?}}. Add {{always-quote?}}.
162; 0.11.1 : Fix {{writer-spec}} defaults.
163; 0.11.0 : Add {{reader-spec}}, ''csv-out'' stuff.
164; 0.10.2 : Escape character, '\', in quoted strings.
165; 0.10.1 :
166; 0.10.0 : Release of csv:0.10 for Chicken
167
168
169== License
170
171[[http://www.gnu.org/licenses/lgpl.html|LGPL 3]]
Note: See TracBrowser for help on using the repository browser.