Handle "ragged right" fixed width files, fix #82.

This commit is contained in:
Dimitri Fontaine 2014-06-17 17:24:07 +02:00
parent 9ad98c5c2a
commit 88eba90776

View File

@ -34,9 +34,12 @@
(defun parse-row (fixed-cols-specs line)
"Parse a single line of FIXED input file and return a row of columns."
(loop :for opts :in fixed-cols-specs
(loop :with len := (length line)
:for opts :in fixed-cols-specs
:collect (destructuring-bind (&key start length &allow-other-keys) opts
(subseq line start (+ start length)))))
(let ((end (+ start length)))
(when (<= end len)
(subseq line start end))))))
(defmethod map-rows ((fixed copy-fixed) &key process-row-fn)
"Load data from a text file in Fixed Columns format.