Simplify the update-data function.
This commit is contained in:
parent
ae2de95d52
commit
ec51a0c919
1 changed files with 6 additions and 8 deletions
|
@ -81,15 +81,13 @@
|
|||
;; Apply the specified updates to data (a list of rows
|
||||
;; read from the CSV). If a 'skip value is specified, drop
|
||||
;; this many leading rows. If a 'header is present, only
|
||||
;; apply the updates to the succeeding rows.
|
||||
;; apply the updates to the succeeding rows, preserving
|
||||
;; the header as-is.
|
||||
(define (update-data spec data)
|
||||
(let* ((data (drop data (or (assq-ref spec 'skip) 0)))
|
||||
(header (if (assq-ref spec 'header) (car data) #f))
|
||||
(data (if header (cdr data) data)))
|
||||
(for-each (process-row spec) data)
|
||||
(if header
|
||||
(cons header data)
|
||||
data)))
|
||||
(let* ((skip (assq-ref spec 'skip))
|
||||
(data (if skip (drop data skip) data)))
|
||||
(for-each (process-row spec) (if (assq-ref spec 'header) (cdr data) data))
|
||||
data))
|
||||
|
||||
;; Apply the updates defined in `spec` to the statement read
|
||||
;; from input-path and write the updated data to output-path.
|
||||
|
|
Loading…
Reference in a new issue