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

  1. Outdated egg!
  2. csv-xml
  3. Documentation
    1. Input
      1. csv-reader?
      2. check-csv-reader
      3. error-csv-reader
      4. reader-spec
      5. csv-reader-spec?
      6. check-csv-reader-spec
      7. error-csv-reader-spec
    2. Output
      1. make-csv-writer-maker
      2. make-csv-writer
      3. csv-writer?
      4. check-csv-writer
      5. error-csv-writer
      6. writer-spec
      7. csv-writer-spec?
      8. check-csv-writer-spec
      9. error-csv-writer-spec
      10. list->csv
  4. Usage
  5. Author
  6. Bugs & Limitations
  7. Version history
  8. License

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) => boolean

Is the OBJECT a csv-reader?

check-csv-reader

[procedure] (check-csv-reader LOC OBJECT [ARG-NAME]) => csv-reader-procedure

error-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-spec

csv-reader-spec?

[procedure] (csv-reader-spec? OBJECT) => boolean

Is the OBJECT a csv-reader-spec?

check-csv-reader-spec

[procedure] (check-csv-reader-spec LOC OBJECT [ARG-NAME]) => csv-reader-spec

error-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) => boolean

Is the OBJECT a csv-writer?

check-csv-writer

[procedure] (check-csv-writer LOC OBJECT [ARG-NAME]) => csv-writer-procedure

error-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-spec

NEWLINE-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) => boolean

Is the OBJECT a csv-writer-spec?

check-csv-writer-spec

[procedure] (check-csv-writer-spec LOC OBJECT [ARG-NAME]) => csv-writer-spec

error-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

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

License

LGPL 3