Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

newbie post - by delimited text file reader suite any good?

5 views
Skip to first unread message

Robert L.

unread,
Sep 19, 2017, 10:17:38 PM9/19/17
to
Rob Warnock wrote:

> > (with-open-file (s "x^2.txt")
> (loop for line = (read-line s nil nil)
> while line
> collect (split-sequence:split-sequence #\tab line)))
>
> (("0" "0") ("0.010101" "0.00010203") ("0.020202" "0.000408122")
> ("0.030303" "0.000918274"))


That won't work:

* (split-sequence:split-sequence #\tab "foo bar")

debugger invoked on a SB-INT:SIMPLE-READER-PACKAGE-ERROR in thread
#<THREAD "main thread" RUNNING {23EAC151}>:
Package SPLIT-SEQUENCE does not exist.



However, this will work:

(require srfi/13) ; string-tokenize
(require srfi/14) ; char sets
(require srfi/42) ; list-ec

(call-with-input-file "input.dat"
(lambda (p)
(list-ec (:port line p read-line)
(string-tokenize line (char-set-complement (char-set #\space))))))

(("foo" "5")
("bar" "20")
("baz" "4")
("-9.9" "foo" "6")
("foobar" "23")
("foobar" "3")
("bar" "68")
("baz" "33"))


--
Despite its proximity and high level of economic development, Israel has
refused to take any Syrian refugees. "We will not allow Israel to be submerged
by a wave of illegal migrants and terrorist activists," Benjamin Netanyahu has
said. archive.org/details/MarkCollettTheJewishRoleInTheRefugeeCrisis
0 new messages