Bigloo

22. Bigloo The Programming Language (4.7a) User manual for version 4.7a February 2026 -- CSV

main page
top: | Bigloo The Programming Language (4.7a) User manual for version 4.7a February 2026
CSV
Chapters
| This chapter describes the Bigloo API for processing CSV spreadsheets. This chapter has been written by Joseph Donaldson, as the implementation of the CSV library.
### 22.1 Overview
The Bigloo csv library supports the parsing of csv and csv-like data. By default, it enables the parsing of comma, tab, and pipe separated data. In addition, facilities are provided that enable extending the library to support additonal csv-like formats. The rest of this document describes the Bigloo csv application programming interface.
### 22.2 API Reference
read-csv-record input-port [custom-lexer] | bigloo procedure
`read-csv-record` has 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-error` or `&io-parse-error` exception.
read-csv-records input-port [custom-lexer] | bigloo procedure
`read-csv-records` has 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-error` or `&io-parse-error exception`.
csv-for-each proc input-port [custom-lexer] | bigloo procedure
`csv-for-each` has 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-error` or `&io-parse-error exception`.
csv-map proc input-port [custom-lexer] | bigloo procedure
`csv-map` has 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 applying `proc` to each record as a list. Upon error, it will throw an `&invalid-port-error` or `&io-parse-error` exception.
make-csv-lexer sep quot | bigloo form
`make-csv-lexer` has two required arguments, a character used to separate records and a character for quoting. It returns custom lexer.
bigloo variable +csv-lexer+ | variable
`+csv-lexer+` is a bigloo-csv lexer supporting the standard comma-separated value format.
bigloo variable +tsv-lexer+ | variable
`+tsv-lexer+` is a bigloo-csv lexer supporting the tab-separated value format.
bigloo variable +psv-lexer+ | variable
`+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))))

This Html page has been produced by Skribe.
Last update Thu Feb 19 09:15:02 2026.