manpagez: man pages & more
info bigloo
Home | html | info | man
[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

22.2 API Reference

bigloo procedure: read-csv-record input-port [custom-lexer]

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.

bigloo procedure: read-csv-records input-port [custom-lexer]

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.

bigloo procedure: csv-for-each proc input-port [custom-lexer]

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.

bigloo procedure: csv-map proc input-port [custom-lexer]

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.

bigloo form: make-csv-lexer sep quot

make-csv-lexer has 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.

© manpagez.com 2000-2024
Individual documents may contain additional copyright information.