Read data from CSV file
This commit is contained in:
parent
5c8e3c9234
commit
6301fa651d
3 changed files with 13 additions and 10 deletions
21
demo.ss
21
demo.ss
|
@ -2,16 +2,17 @@
|
|||
|
||||
(export main)
|
||||
|
||||
(import :std/format
|
||||
:std/misc/string
|
||||
:dlozeve/fancy/format
|
||||
(import :std/iter
|
||||
:std/text/csv
|
||||
:dlozeve/uniplot/lineplot)
|
||||
|
||||
(def (main . args)
|
||||
(let* ((xs (iota 1000 0 0.01))
|
||||
(ys1 (map cos xs))
|
||||
(ys2 (map (lambda (x) (/ 1 (+ 0.5 x))) xs))
|
||||
(ys3 (map (lambda (x) (sin (* 2 x))) xs)))
|
||||
(displayln (line-plot [xs ys1 ys2 ys3]
|
||||
xlabel: "time"
|
||||
names: ["cos(time)" "1 / (time + 0.5)" "sin(2 × time)"]))))
|
||||
(def csv (read-csv-lines (current-input-port)))
|
||||
(def names (car csv))
|
||||
(def lsts
|
||||
(apply map list
|
||||
(for/collect ((row csv))
|
||||
(for/collect ((x row))
|
||||
(or (string->number x) +nan.0)))))
|
||||
(displayln (line-plot lsts
|
||||
xlabel: (car names) names: (cdr names))))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue