Indeed, the COPY INTO requires a CREATE TABLE beforehand. As of right now, there is no generic way to infer a schema. The main issue here is the massive diversity of CSV encodings.
That being said, the MonetDB.R connector does support schema "guessing" through the monetdb.read.csv function.
Also, I have been working on a Python script to automate the CSV loading task. The script (importer.py) is available from my CWI page. It works as follows:
./importer.py -h
usage: importer.py [-h] [--database DATABASE] [--port PORT] [--user USER]
[--password PASSWORD] [--header] [--yes]
files [files ...]
A "smarter" CSV loader for MonetDB, v.0.3, [email protected], 2014-05
positional arguments:
files One or many CSV files to be imported
optional arguments:
-h, --help show this help message and exit
--database DATABASE Database name to connect to
--port PORT MonetDB TCP port, defaults to 50000
--user USER MonetDB username, defaults to "monetdb"
--password PASSWORD MonetDB password, defaults to "monetdb"
--header set if given CSV file has a header in the first line
--yes if set, assume Yes on all questions
Usage example:
./importer.py --database acs ~/Desktop/adult.csv
Now probing '/ufs/hannes/Desktop/adult.csv':
OK, I am going to run the following commands on your DB acs:
CREATE TABLE adult5 (C1 DOUBLE, C2 STRING, C3 STRING, C4 STRING, C5 STRING, C6 STRING, C7 STRING, C8 STRING, C9 STRING, C10 STRING, C11 DOUBLE, C12 STRING, C13 BIGINT);
COPY 35469 OFFSET 1 RECORDS INTO adult5 FROM '/ufs/hannes/Desktop/adult.csv' USING DELIMITERS ',','\n','"' NULL AS '' LOCKED;
Proceed? [Y/n] y
imported 30162 rows from /ufs/hannes/Desktop/adult.csv in 3 second(s)
If there are any problems, please let me know.