Paste: bdi format parser
Author: | hsuh |
Mode: | factor |
Date: | Fri, 5 Feb 2010 01:49:29 |
Plain Text |
USING: accessors io.encodings.ascii io.files kernel locals
sequences math math.parser ;
IN: bdi
TUPLE: quote codneg preabe premax premin premed preult ;
: clean-name ( name -- clean )
[ " \t" member? ] trim ;
: string>price ( string -- float )
dup length 2 - cut
[ string>number ] bi@
100 / + ;
: only-reg2 ( seq -- seq )
[ 2 head "02" = ] filter ;
:: parse-reg2 ( line -- obj )
quote new
57 69 line subseq clean-name >>codneg
90 101 line subseq string>price >>preabe
101 112 line subseq string>price >>premax
112 123 line subseq string>price >>premin
123 134 line subseq string>price >>premed
134 145 line subseq string>price >>preult ;
: file>bdi ( path -- bdi )
ascii file-lines only-reg2
[ parse-reg2 ] map ;
New Annotation