diff --git a/Makefile b/Makefile index 2abdb40..0f60b76 100644 --- a/Makefile +++ b/Makefile @@ -44,25 +44,26 @@ BBSTOOL-DEPS=bbstool.scm testing.import.scm listing.import.scm \ member-record.import.scm configuration.import.scm \ progress.import.scm table.import.scm cards.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 \ month.scm period.scm ansi.scm command-line.scm \ members-base.scm utils.scm primes.scm member-record.scm \ configuration.scm progress.scm table.scm cards.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 \ command-line.o members-base.o utils.o primes.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 \ dictionary.so command-line.so members-base.so utils.so \ primes.so member-record.so configuration.so progress.so \ table.so cards.so members-print.so member-fees.so \ - members-dir.so + members-dir.so csv-simple.so .PHONY: imports imports: $(BBSTOOL-DEPS) @@ -225,3 +226,9 @@ MEMBERS-DIR-SOURCES=members-dir.scm testing.import.scm \ members-dir.so: members-dir.o members-dir.o: members-dir.import.scm 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) diff --git a/csv-simple.scm b/csv-simple.scm new file mode 100644 index 0000000..8e99762 --- /dev/null +++ b/csv-simple.scm @@ -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 +;; +;; 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)) + + ) +