Magic Pipes
Documentation
Login

mpcsv-read [-R record-sep-char] [-T|--no-fields|-D field-sep-char] [-q|-Q field-quote-char] [-c|-C char-quote-char] [--no-embedded-quotes] [--no-embedded-double-quotes]

Reads comma separated values (or, if a field separator char is specified, values separated by that delimiter; or if -T is specified, tab-separated values) from standard input. If --no-fields is specified, every record has a single field.

Records are terminated by newlines, unless -R is used to specify a different terminator.

Fields enclosed in quote (") characters can contain embedded record and field separators. The quote character can be overridden with -Q, or this feature disabled with -q.

Characters prefixed with a backslach (\) character will be treated verbatim as part of the field value, even if they're a separator or quote character. The prefix quote character can be overridden with -C, or this feature disabled with -c.

Prefix quotes can be used inside field quotes, so "Hello \"world\"" will be treated as Hello "world", unless --no-embedded-quotes is specified

A pair of adjacent field quotes inside a quoted field will be interpreted as a single quote, so "Hello ""world""" will be treated as Hello "world", unless --no-embedded-double-quotes is specified.

Each record (line) read from standard input is written as a list sexpr of the values in order.

Examples

mpcsv-read < test.csv | mpmap 'list->vector' | mpjson-write
mpcsv-read -D : < /etc/passwd | mpmap car # returns a list of usernames