Jennie
Thank you very much!!! it worked for me on versions Dec2016-SP5 & Jun2016-SP2 (also)

Rgds
Ariel



On Mon, Jul 24, 2017 at 10:09 AM, Ying Zhang <Y.Zhang@cwi.nl> wrote:
Hai Ariel,

Allowing omitted columns in CSV files was added later, so the documentation for that is not yet published.
The syntax is:

COPY … INTO table_name (dest_col1, dest_col2, dest_col3, …) FROM <file> (src_col3, src_col1, src_col2) …

Note from the above syntax that the columns in the CSV file don’t have to be in the same order of the columns in the table.

I tried the following example (using Jul2017):

$ cat cars.csv
Ford,E350
Mercury,Cougar

$ mclient

sql>create table cars (y string, make string, model string);
operation successful (4.622ms)
sql>copy into cars(model, make) from '/Users/jennie/cars.csv' (make, model)  delimiters ',','\n';
2 affected rows (49.872ms)
sql>select * from cars;
+------+---------+--------+
| y    | make    | model  |
+======+=========+========+
| null | Ford    | E350   |
| null | Mercury | Cougar |
+------+---------+--------+
2 tuples (2.523ms)
sql>copy into cars(model, make) from '/Users/jennie/cars.csv' (model, make)  delimiters ',','\n';
2 affected rows (49.438ms)
sql>select * from cars;
+------+---------+---------+
| y    | make    | model   |
+======+=========+=========+
| null | Ford    | E350    |
| null | Mercury | Cougar  |
| null | E350    | Ford    |
| null | Cougar  | Mercury |
+------+---------+---------+
4 tuples (4.323ms)

Hope it works for you

Regards,
Jennie


> On 21 Jul 2017, at 19:20, Ariel Abadi <aabadi@starconnecting.com> wrote:
>
> Hi
> Im trying to upload a FILE into one table. The FILE has all the fields of the table, except for the last field which is the updated time.
>
> For that reason I have created the table with the field:
>
> "nrm_now"     TIMESTAMP(0)  DEFAULT current_timestamp()
>
> BUT when im trying to insert the FILE (COY INTO test_20170711 from FILE .... ), there is an error:
>
> Failed to import table 'test_20170711', Column value 143 missing
>
> Does anybody can help me? Am I doing something wrong?  Which should be the best way to implement this?
>
> Thnks in advance
> Ariel
>
>
> _______________________________________________
> users-list mailing list
> users-list@monetdb.org
> https://www.monetdb.org/mailman/listinfo/users-list

_______________________________________________
users-list mailing list
users-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/users-list