Magic Pipes
Documentation
Login

mptable2alist [-H] key...

Accepts lists on standard input, and converts them to alists by using the supplied keys as alist keys and the elements of the input list as alist values, in the same order.

If -H is specified, then rather than using a list of keys on the command line, the first list read from the input is used as the list of keys.

A mismatch between the length of the list of keys and the length of any input list causes an error to be signalled.

This useful for interoperating between mpcsv and mpsqlite.

Examples

$ echo '(1 2)' | mptable2alist a b
((a . 1) (b . 2))
echo '(a b) (1 2)' | mptable2alist -H
((a . 1) (b . 2))
$ ls -l *.scm | \
       mpre '(seq (=> perms (= 10 any)) (* space) (=> linkcount integer) (* space) (=> user symbol) (* space) (=> group symbol) (* space) (=> size integer) (* space) (=> modtime symbol (* space) integer (* space) integer ":" integer) (* space) (=> name (* any)))' | \
       mpalist2table -H name size user | mpcsv-write
name,size,user
magic-pipes.import.scm,2546,alaric
magic-pipes-runtime.import.scm,1923,alaric
magic-pipes-runtime.scm,14470,alaric
magic-pipes.scm,11906,alaric
mpalist2table.scm,1725,alaric
mpcsv-read.scm,1767,alaric
mpcsv-write.scm,1561,alaric
mpforeach.scm,932,alaric
mpjson-read.scm,838,alaric
mpjson-write.scm,661,alaric
mpls.scm,2247,alaric
mpre.scm,3019,alaric
mpsqlite.scm,11200,alaric
mptable2alist.scm,1588,alaric