You are looking at historical revision 39572 of this page. It may differ significantly from its current revision.
Outdated egg!
This is an egg for CHICKEN 4, the unsupported old release. You're almost certainly looking for the CHICKEN 5 version of this egg, if it exists.
If it does not exist, there may be equivalent functionality provided by another egg; have a look at the egg index. Otherwise, please consider porting this egg to the current version of CHICKEN.
csv-xml
Documentation
A CHICKEN version of "csv-scheme". Some additions/extensions to the original.
Input
See csv-scheme for the full documentation.
csv-reader?
[procedure] (csv-reader? OBJECT) => booleanIs the OBJECT a csv-reader?
check-csv-reader
[procedure] (check-csv-reader LOC OBJECT [ARG-NAME]) => csv-reader-procedureerror-csv-reader
[procedure] (error-csv-reader LOC OBJECT [ARG-MESSAGE []])reader-spec
[procedure] (reader-spec [(newline-type: NEWLINE-TYPE 'lax) (separator-chars: SEPARATOR-CHARS '(#\,)) (quote-char: QUOTE-CHAR #\") (comment-chars: COMMENT-CHARS '()) (quote-doubling-escapes?: QUOTE-DOUBLING-ESCAPES? #t) (whitespace-chars: WHITESPACE-CHARS '(#\space)) (strip-leading-whitespace?: STRIP-LEADING-WHITESPACE? #f) (strip-trailing-whitespace?: STRIP-TRAILING-WHITESPACE? #f) (newlines-in-quotes?: NEWLINES-IN-QUOTES? #t)]) => csv-reader-speccsv-reader-spec?
[procedure] (csv-reader-spec? OBJECT) => booleanIs the OBJECT a csv-reader-spec?
check-csv-reader-spec
[procedure] (check-csv-reader-spec LOC OBJECT [ARG-NAME]) => csv-reader-specerror-csv-reader-spec
[procedure] (error-csv-reader-spec LOC OBJECT [ARG-MESSAGE []])Output
make-csv-writer-maker
[procedure] (make-csv-writer-maker [WRITER-SPEC]) => (#!optional csv-writer-spec -> ((or output-port string) -> (* -> undefined)))See writer-spec below for the default WRITER-SPEC.
make-csv-writer
[procedure] (make-csv-writer OUT-OR-STR [WRITER-SPEC]) => (* -> undefined)Returns a procedure of 1 argument, a scheme-object, the ROW-DATA-OBJECT.
OUT-OR-STR is output-port or string. A string is interpreted as a pathname to yield an output-port.
See writer-spec below for the default WRITER-SPEC.
When the ROW-DATA-OBJECT is a list then it is interpreted as row data. Otherwise assumed to be a comment.
The ROW-DATA-OBJECT argument will be converted to an output string, according to the associated csv-writer-spec, and printed to the associated output-port.
csv-writer?
[procedure] (csv-writer? OBJECT) => booleanIs the OBJECT a csv-writer?
check-csv-writer
[procedure] (check-csv-writer LOC OBJECT [ARG-NAME]) => csv-writer-procedureerror-csv-writer
[procedure] (error-csv-writer LOC OBJECT [ARG-MESSAGE []])writer-spec
[procedure] (writer-spec [(newline-char: NEWLINE-CHAR #t) (separator-char: SEPARATOR-CHAR #\,) (quote-char: QUOTE-CHAR #\") (comment-char: COMMENT-CHAR #\#) (quote-doubling-escapes?: QUOTE-DOUBLING-ESCAPES? #t) (quote-controls?: QUOTE-CONTROLS? #t) (always-quote?: ALWAYS-QUOTE? #t)]) => csv-writer-specNEWLINE-CHAR is #t, cr, lf, or crlf.
COMMENT-CHAR is #f, or a character. #f means no comment support.
QUOTE-DOUBLING-ESCAPES? is a boolean.
QUOTE-CONTROLS? is a boolean, quoting strings with iso-control characters?
ALWAYS-QUOTE? is a boolean.
csv-writer-spec?
[procedure] (csv-writer-spec? OBJECT) => booleanIs the OBJECT a csv-writer-spec?
check-csv-writer-spec
[procedure] (check-csv-writer-spec LOC OBJECT [ARG-NAME]) => csv-writer-specerror-csv-writer-spec
[procedure] (error-csv-writer-spec LOC OBJECT [ARG-MESSAGE []])list->csv
[procedure] (list->csv LS [WRITER-OR-OUT])LS is a list-of list | string, a list of row-item.
WRITER-OR-OUT is a csv-writer or output-port. Default is the (current-output-port). Note that when an output-port is specified the default csv-writer-spec will be used.
When the current row-item is a string, and not a list, then it is treated as a line-comment. Note that comments are processed only when the associated csv-writer-spec comment-char is a character.
;assumes string output & comment-char is #\# (list->csv '((1 22 333) "a comment" (11 2222 333333))) ;=> "\"1\",\"22\",\"333\"\n#a comment\n\"11\",\"2222\",\"333333\"\n"
Usage
(require-extension csv-xml)
Author
Neil van Dyke
Kon Lovett for CHICKEN
Bugs & Limitations
- The quote-doubling-escapes? and quote-controls? are currently ignored by csv-writer.
Version history
- 0.12.1
- 0.12.0
- Use quote-doubling-escapes? and quote-controls?. Add always-quote?.
- 0.11.1
- Fix writer-spec defaults.
- 0.11.0
- Add reader-spec, csv-out stuff.
- 0.10.2
- Escape character, '\', in quoted strings.
- 0.10.1
- 0.10.0
- Release of csv:0.10 for Chicken