From 65035b1bc6add9eb1adc39a3bef21bb0ba07be19 Mon Sep 17 00:00:00 2001 From: Dimitri Fontaine Date: Tue, 8 Oct 2013 22:16:52 +0200 Subject: [PATCH] Allow for loading CSV files not using any field quoting. --- parser.lisp | 4 ++++ test/csv.load | 3 +-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/parser.lisp b/parser.lisp index fd8a6bb..7c9559c 100644 --- a/parser.lisp +++ b/parser.lisp @@ -905,6 +905,9 @@ Here's a quick description of the format we're parsing here: (declare (ignore f e o b)) (cons :quote sep)))) +(defrule option-fields-not-enclosed (and kw-fields kw-not kw-enclosed) + (:constant (cons :quote nil))) + (defrule quote-quote "double-quote" (:constant "\"\"")) (defrule backslash-quote "backslash-quote" (:constant "\\\"")) (defrule escaped-quote-name (or quote-quote backslash-quote)) @@ -931,6 +934,7 @@ Here's a quick description of the format we're parsing here: (defrule csv-option (or option-truncate option-skip-header + option-fields-not-enclosed option-fields-enclosed-by option-fields-escaped-by option-fields-terminated-by)) diff --git a/test/csv.load b/test/csv.load index febb11f..d84cabd 100644 --- a/test/csv.load +++ b/test/csv.load @@ -3,6 +3,5 @@ LOAD CSV INTO postgresql://dim@localhost:54393/yagoa?communaute_profil WITH truncate, - fields optionally enclosed by '"', - fields escaped by double-quote, + fields not enclosed, fields terminated by '\t';