Common Lisp Package: FARE-CSV

README:

FUNCTION

Public

READ-CSV-FILE (PATHNAME &REST KEYS &KEY ELEMENT-TYPE EXTERNAL-FORMAT)

Open the file designated by PATHNAME, using the provided keys if any, and call READ-CSV-STREAM on it.

READ-CSV-LINE (STREAM)

Read one line from STREAM in CSV format, using the current syntax parameters. Return a list of strings, one for each field in the line. Entries are read as strings; it is up to you to interpret the strings as whatever you want.

READ-CSV-STREAM (STREAM)

Read lines from STREAM in CSV format, using the current syntax parameters. Return a list of list of strings, one entry for each line, that contains one entry for each field. Entries are read as strings; it is up to you to interpret the strings as whatever you want.

WRITE-CSV-LINE (FIELDS STREAM)

Format one line of FIELDS to STREAM in CSV format, using the current syntax parameters.

WRITE-CSV-LINES (LINES STREAM)

Given a list of LINES, each of them a list of fields, and a STREAM, format those lines as CSV according to the current syntax parameters.

Private

CHAR-SPACE-P (C)

Is character C some kind of white space? NB: this only handles a tiny subset of whitespace characters, even if restricted to ASCII. However, it's rather portable, and is what the creativyst document specifies. Be careful to not skip a separator, as it could be e.g. a tab!

Undocumented

ACCEPT (X STREAM)

ACCEPT-EOF (STREAM)

ACCEPT-EOL (STREAM)

ACCEPT-P (X STREAM)

ACCEPT-QUOTE (STREAM)

ACCEPT-SEPARATOR (STREAM)

ACCEPT-SPACE (STREAM)

ACCEPT-SPACES (STREAM)

CALL-WITH-CREATIVYST-CSV-SYNTAX (THUNK)

CALL-WITH-RFC4180-CSV-SYNTAX (THUNK)

CALL-WITH-STRICT-RFC4180-CSV-SYNTAX (THUNK)

CHAR-ASCII-TEXT-P (C)

CHAR-NEEDS-QUOTING (X)

STRING-NEEDS-QUOTING (X)

VALID-EOL-P (X)

VALIDATE-CSV-PARAMETERS

WRITE-CSV-FIELD (FIELD STREAM)

WRITE-CSV-STRING-SAFELY (STRING STREAM)

WRITE-QUOTED-STRING (STRING STREAM)

MACRO

Public

WITH-CREATIVYST-CSV-SYNTAX ((&OPTIONAL) &BODY BODY)

bind CSV syntax parameters to the CREATIVYST standard around evaluation of BODY

WITH-RFC4180-CSV-SYNTAX ((&OPTIONAL) &BODY BODY)

bind CSV syntax parameters to the RFC 4180 standard around evaluation of BODY

WITH-STRICT-RFC4180-CSV-SYNTAX ((&OPTIONAL) &BODY BODY)

bind CSV syntax parameters to the strict RFC 4180 standard around evaluation of BODY, forcing CRLF as line ending and disallowing binary data amongst values

Private

DEFSUBST (NAME ARGLIST &BODY BODY)

Declare an inline defun.

VARIABLE

Public

*ALLOW-BINARY*

do we accept non-ascii data?

*EOL*

line ending when exporting CSV

*KEEP-META-INFO*

when parsing, include meta information?

*LINE-ENDINGS*

acceptable line endings when importing CSV

*LOOSE-QUOTE*

can quotes appear anywhere in a field?

*QUOTE*

delimiter of string data; pascal-like quoted as double itself in a string.

*SEPARATOR*

Separator between CSV fields

*SKIP-WHITESPACE*

shall we skip unquoted whitespace around separators?

*UNQUOTED-QUOTEQUOTE*

does a pair of quotes represent a quote outside of quotes? M$, RFC says NIL, csv.3tcl says T

+CR+

String containing a CR (Carriage Return)

+CRLF+

String containing a CRLF line termination

+LF+

String containing a LF (Linefeed)

Private

*ACCEPT-CR*

internal: do we accept cr?

*ACCEPT-CRLF*

internal: do we accept crlf?

*ACCEPT-LF*

internal: do we accept lf?

Undocumented

*CSV-VARIABLES*