Improve documentation and empty strings test cases, now that cl-csv is fixed.

This commit is contained in:
Dimitri Fontaine 2013-10-12 14:36:35 +02:00
parent 138efc3690
commit 4ff7d9ae69
2 changed files with 34 additions and 9 deletions

View File

@ -33,10 +33,13 @@ not found in Quicklisp yet at the time of this writing:
cd ~/quicklisp/local-projects/
git clone https://github.com/marijnh/Postmodern.git
git clone -b empty-strings-and-nil https://github.com/dimitri/cl-csv.git
git clone http://git.tapoueh.org/git/pgloader.git
Now fetch pgloader sources using `git clone` then you can use the #! script.
You might have to modify it because it's now hard coded to use
`/usr/local/bin/sbcl` and you probably want to change that part then:
Now you can use the `#!` script or build a self-contained binary executable
file, as shown below. You might have to modify it the `pgloader.lisp` script
because it's now hard coded to use `/usr/local/bin/sbcl` and you probably
want to change that part then:
./pgloader.lisp --help
@ -48,6 +51,15 @@ download the dependencies.
## Compile into a self-contained binary file
First, make sure you have downloaded all the required Common Lisp
dependencies that pgloader uses, and install the
[buildapp](http://www.xach.com/lisp/buildapp/) application:
$ sbcl
* (ql:quickload "pgloader")
* (ql:quickload "buildapp")
* (buildapp:build-buildapp "./buildapp")
If you just installed *SBCL* and *Quicklisp* to use pgloader, that command
should do it:
@ -55,8 +67,12 @@ should do it:
--asdf-tree ~/quicklisp/dists \
--load-system pgloader \
--entry pgloader:main \
--dynamic-space-size 4096 \
--output pgloader.exe
You can also use the option `--compress-core` if your platform supports it,
so has to reduce the size of the generated binary.
When you're a Common Lisp developper or otherwise already using Quicklisp
with some *local-projects* and a local source registry setup for *asdf*, use
a command line like this:
@ -67,6 +83,7 @@ a command line like this:
--asdf-tree ~/quicklisp/dists \
--load-system pgloader \
--entry pgloader:main \
--dynamic-space-size 4096 \
--output pgloader.exe
That command requires a `manifest.ql` file that you can obtain with the lisp
@ -76,9 +93,16 @@ command:
## Usage
Use the `--file` parameter to give pgloader a command file to parse, it will start
Give as many command files that you need to pgloader:
./pgloader.lisp -f <file.load>
./pgloader.lisp <file.load>
See the documentation file `pgloader.1.md` for details. You can compile that
file into a manual page or an HTML page thanks to the `pandoc` application:
$ apt-get install pandoc
$ pandoc pgloader.1.md -o pgloader.1
$ pandoc pgloader.1.md -o pgloader.html
## TODO

View File

@ -1,5 +1,5 @@
LOAD CSV
FROM INLINE (f1, f2 null if "", f3)
FROM INLINE
INTO postgresql://dim@localhost:54393/dim?nulls (f1, f2, f3)
WITH truncate,
fields optionally enclosed by '"',
@ -10,9 +10,10 @@ LOAD CSV
$$ drop table if exists nulls; $$,
$$ create table if not exists nulls (id serial, f1 text, f2 text, f3 text); $$;
"quoted empty string","","should be empty string when the CSV parser is improved"
"empty string",,"should be null"
"quoted empty string","","should be empty string"
"no value between separators",,"should be null"
"quoted blanks"," ","should be blanks"
"blanks", ,"should be null"
"unquoted blanks between separators", ,"should be null"
"unquoted string",no quote,"should be 'no quote'"
"quoted separator","a,b,c","should be 'a,b,c'"