-
Notifications
You must be signed in to change notification settings - Fork 1
Content automatically generated. Contributions from the community are very welcomed at the bottom of this file.
- Intro
- Dependencies
- Test dependencies
- Foreign dependencies
- API
- Examples
- Author(s)
- Maintainer(s)
- Version
- License
- Tags
A CSV reader/writer library. RFC4180 compliant - http://tools.ietf.org/html/rfc4180 - but allowing:
- choice of separator character, e.g. tab instead of comma
- choice of quote character, e.g. single instead of double-quote
- "CR LF", "CR" or "LF" are all accepted as line endings when reading
The CSV reader/writer uses a standard input or output port. Records are retrieved or written as lists of field values. Fields are always read as strings. Fields are written using display
unless they are strings needing quoting, when they are written character by character, or symbols, which are first converted to strings.
None
None
None
Creates a csv-reader object:
- no arguments: uses current input port, comma as separator and double-quote for quote character
- one argument: specifies input port
- two arguments: specifies input port and separator character
- three arguments: specifies input port, separator character and quote character
Reads a single record (list of fields) from given reader, or current-input-port if no reader given.
Reads a list of records (list of fields) from given reader, or current-input-port if no reader given.
> (import (cyclone csv) (scheme file))
> (with-input-from-file "data.csv" (lambda () (csv-read-all)))
(("123" "field 2" "456") ("789" "see, comma" "12"))
Creates a csv-writer object:
- no arguments: uses current-output-port, comma as separator and double-quote for quote character
- one argument: specifies output port
- two arguments: specifies output port and separator character
- three arguments: specifies output port, separator character and quote character
Writes a single record (list of fields) in CSV format:
- one argument: the record, writes to the current-output-port with comma as separator and double-quote for quote character
- two arguments: the record and a csv-writer object
Writes a list of records in CSV format:
- one argument: the records, writes to the current-output-port with comma as separator and double-quote for quote character
- two arguments: the records and a csv-writer object
> (import (cyclone csv) (scheme file))
> (with-output-to-file "data.csv"
(lambda () (csv-write-all '((123 "field 2" 456) (789 "see, comma" 012)))))
$ more data.csv
123,field 2,456
789,"see, comma",12
(import (scheme base)
(cyclone csv))
(with-output-to-file "data.csv"
(lambda () (csv-write-all '((123 "field 2" 456) (789 "see, comma" 012)))))
$ more data.csv
123,field 2,456
789,"see, comma",12
(with-input-from-file "data.csv" (lambda () (csv-read-all)))
=>
(("123" "field 2" "456") ("789" "see, comma" "12"))
Peter Lane
Arthur Maciel
0.1.1
BSD