csv-xml

  1. csv-xml
  2. 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
  3. Usage
  4. Author
  5. Bugs & Limitations
  6. Version history
  7. 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 'lax) (separator-chars '(#\,)) (quote-char #\") (quote-doubling-escapes? #t) (comment-chars '()) (whitespace-chars '(#\space)) (strip-leading-whitespace? #f) (strip-trailing-whitespace? #f) (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 #t) (separator-char #\,) (quote-char #\") (comment-char #\#) (quote-doubling-escapes? #t) (quote-controls? #t)]) => csv-writer-spec

NEWLINE-CHAR is #t, cr, lf, or crlf. #t is the platform default.

COMMENT-CHAR is #f, or a character. #f means no comment support. #\# is the default.

quote-doubling-escapes? and quote-controls? are currently ignored.

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