Add simple CSV module skeleton.
This commit is contained in:
parent
cf4652084f
commit
3c166fddb1
2 changed files with 56 additions and 4 deletions
15
Makefile
15
Makefile
|
@ -44,25 +44,26 @@ BBSTOOL-DEPS=bbstool.scm testing.import.scm listing.import.scm \
|
||||||
member-record.import.scm configuration.import.scm \
|
member-record.import.scm configuration.import.scm \
|
||||||
progress.import.scm table.import.scm cards.import.scm \
|
progress.import.scm table.import.scm cards.import.scm \
|
||||||
member-parser.import.scm members-print.import.scm \
|
member-parser.import.scm members-print.import.scm \
|
||||||
member-fees.import.scm members-dir.import.scm
|
member-fees.import.scm members-dir.import.scm \
|
||||||
|
csv-simple.import.scm
|
||||||
|
|
||||||
BBSTOOL-SOURCES=bbstool.scm testing.scm listing.scm dictionary.scm \
|
BBSTOOL-SOURCES=bbstool.scm testing.scm listing.scm dictionary.scm \
|
||||||
month.scm period.scm ansi.scm command-line.scm \
|
month.scm period.scm ansi.scm command-line.scm \
|
||||||
members-base.scm utils.scm primes.scm member-record.scm \
|
members-base.scm utils.scm primes.scm member-record.scm \
|
||||||
configuration.scm progress.scm table.scm cards.scm \
|
configuration.scm progress.scm table.scm cards.scm \
|
||||||
members-print.scm member-parser.scm member-fees.scm \
|
members-print.scm member-parser.scm member-fees.scm \
|
||||||
members-dir.scm
|
members-dir.scm csv-simple.scm
|
||||||
|
|
||||||
BBSTOOL-OBJS=testing.o listing.o month.o period.o ansi.o dictionary.o \
|
BBSTOOL-OBJS=testing.o listing.o month.o period.o ansi.o dictionary.o \
|
||||||
command-line.o members-base.o utils.o primes.o \
|
command-line.o members-base.o utils.o primes.o \
|
||||||
member-record.o configuration.o progress.o table.o cards.o \
|
member-record.o configuration.o progress.o table.o cards.o \
|
||||||
members-print.o member-fees.o members-dir.o
|
members-print.o member-fees.o members-dir.o csv-simple.o
|
||||||
|
|
||||||
BBSTOOL-SHARED=testing.so listing.so month.so period.so ansi.so \
|
BBSTOOL-SHARED=testing.so listing.so month.so period.so ansi.so \
|
||||||
dictionary.so command-line.so members-base.so utils.so \
|
dictionary.so command-line.so members-base.so utils.so \
|
||||||
primes.so member-record.so configuration.so progress.so \
|
primes.so member-record.so configuration.so progress.so \
|
||||||
table.so cards.so members-print.so member-fees.so \
|
table.so cards.so members-print.so member-fees.so \
|
||||||
members-dir.so
|
members-dir.so csv-simple.so
|
||||||
|
|
||||||
.PHONY: imports
|
.PHONY: imports
|
||||||
imports: $(BBSTOOL-DEPS)
|
imports: $(BBSTOOL-DEPS)
|
||||||
|
@ -225,3 +226,9 @@ MEMBERS-DIR-SOURCES=members-dir.scm testing.import.scm \
|
||||||
members-dir.so: members-dir.o
|
members-dir.so: members-dir.o
|
||||||
members-dir.o: members-dir.import.scm
|
members-dir.o: members-dir.import.scm
|
||||||
members-dir.import.scm: $(MEMBERS-DIR-SOURCES)
|
members-dir.import.scm: $(MEMBERS-DIR-SOURCES)
|
||||||
|
|
||||||
|
CSV-SIMPLE-SOURCES=csv-simple.scm
|
||||||
|
|
||||||
|
csv-simple.so: csv-simple.o
|
||||||
|
csv-simple.o: csv-simple.import.scm
|
||||||
|
csv-simple.import.scm: $(CSV-SIMPLE-SOURCES)
|
||||||
|
|
45
csv-simple.scm
Normal file
45
csv-simple.scm
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
;;
|
||||||
|
;; csv-simple.scm
|
||||||
|
;;
|
||||||
|
;; Simple, incomplete and incorrect but fast CSV loader.
|
||||||
|
;;
|
||||||
|
;; ISC License
|
||||||
|
;;
|
||||||
|
;; Copyright 2023 Brmlab, z.s.
|
||||||
|
;; Dominik Pantůček <dominik.pantucek@trustica.cz>
|
||||||
|
;;
|
||||||
|
;; Permission to use, copy, modify, and/or distribute this software
|
||||||
|
;; for any purpose with or without fee is hereby granted, provided
|
||||||
|
;; that the above copyright notice and this permission notice appear
|
||||||
|
;; in all copies.
|
||||||
|
;;
|
||||||
|
;; THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
|
||||||
|
;; WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
|
||||||
|
;; WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
|
||||||
|
;; AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
|
||||||
|
;; CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||||
|
;; OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||||
|
;; NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||||
|
;; CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
;;
|
||||||
|
|
||||||
|
(declare (unit csv-simple))
|
||||||
|
|
||||||
|
(module
|
||||||
|
csv-simple
|
||||||
|
(
|
||||||
|
csv-parse
|
||||||
|
)
|
||||||
|
|
||||||
|
(import scheme
|
||||||
|
(chicken base)
|
||||||
|
(chicken keyword))
|
||||||
|
|
||||||
|
(define (csv-parse fn . args)
|
||||||
|
(let ((separator (get-keyword #:separator args (lambda () ";")))
|
||||||
|
(string-delimiter (get-keyword #:string-delimiter args (lambda () "\"")))
|
||||||
|
(lines (read-lines (open-input-file fn))))
|
||||||
|
#f))
|
||||||
|
|
||||||
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue