uniplot/uniplot.ss
Dimitri Lozeve 98c6ab537c Allow plotting very large CSV files
Using apply leads to implementation limits in the number of arguments
which are fairly low. Refactoring everything as folds allows to handle
an arbitrary number of datapoints.
2021-10-23 19:35:10 +02:00

20 lines
474 B
Scheme
Executable file

#!/usr/bin/env gxi
(export main)
(import :std/iter
:std/misc/func
:std/text/csv
:dlozeve/uniplot/lineplot)
(def (parse-number s)
(or (string->number s) +nan.0))
(def (main . args)
(def csv (read-csv-lines (current-input-port)))
(def names (car csv))
(def lsts
(for/fold (lsts (repeat '() (length names)))
((row (cdr csv)))
(map cons (map parse-number row) lsts)))
(displayln (line-plot lsts title: (if (null? args) "" (car args)) names: names)))