| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
22.2 API Reference
| • read-csv-record | ||
| • read-csv-records | ||
| • csv-for-each | ||
| • csv-map | ||
| • make-csv-lexer | ||
| • +csv-lexer+ | comma separated values | |
| • +tsv-lexer+ | tab separated values | |
| • +psv-lexer+ | pipe separated values |
- bigloo procedure: read-csv-record input-port [custom-lexer]
-
read-csv-recordhas one required argument, the input-port of the csv data to parse, and an optional argument indicating the lexer to use, by default the lexer supporting standard csv files. It returns a single record, as a list, or#eof-object. Upon error, it will throw an&invalid-port-erroror&io-parse-errorexception.
- bigloo procedure: read-csv-records input-port [custom-lexer]
-
read-csv-recordshas one required argument, the input-port of the csv data to parse, and an optional argument indicating the lexer to use, by default the lexer supporting standard csv files. It returns all of the records, as a list of lists, or#eof-object. Upon error, it will throw an&invalid-port-erroror&io-parse-error exception.
- bigloo procedure: csv-for-each proc input-port [custom-lexer]
-
csv-for-eachhas two required arguments, a procedure to apply to each record and the input-port of the csv data to parse, and an optional argument indicating the lexer to use, by default the lexer supporting standard csv files. It returns#unspecified. Upon error, it will throw an&invalid-port-erroror&io-parse-error exception.
- bigloo procedure: csv-map proc input-port [custom-lexer]
-
csv-maphas two required arguments, a procedure to apply to each record and the input-port of the csv data to parse, and an optional argument indicating the lexer to use, by default the lexer supporting standard csv files. It returnsthe results of applyingprocto each record as a list. Upon error, it will throw an&invalid-port-erroror&io-parse-errorexception.
- bigloo form: make-csv-lexer sep quot
-
make-csv-lexerhas two required arguments, a character used to separate records and a character for quoting. It returns custom lexer.
- Variable: bigloo variable +csv-lexer+
+csv-lexer+ is a bigloo-csv lexer supporting the standard comma-separated value format.
- Variable: bigloo variable +tsv-lexer+
+tsv-lexer+ is a bigloo-csv lexer supporting the tab-separated value format.
- Variable: bigloo variable +psv-lexer+
+psv-lexer+ is a bigloo-csv lexer supporting the pipe-separated value format.
The following is a simple example of using the bigloo-csv library. It parses a single record from the given csv data and prints it.
(module example
(library bigloo-csv)
(main main))
(define +csv-data+ "dog,cat,horse\npig,cow,squirrel")
(define (main args)
(let ((in (open-input-string +csv-data+)))
(unwind-protect
(print (read-csv-record in))
(close-input-port in))))
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated on March 31, 2014 using texi2html 5.0.
