Bug 6767

Summary: Add a 'HEADER' option to export data using COPY with column names
Product: SQL Reporter: Fabio <palmaresk8>
Component: allAssignee: SQL devs <bugs-sql>
Status: NEW ---    
Severity: enhancement    
Priority: Normal    
Version: 11.33.11 (Apr2019-SP1)   
Hardware: All   
OS: All   

Description Fabio 2019-10-03 15:22:07 CEST
User-Agent:       Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36
Build Identifier: 

It would be really useful if MonetDB could have the ability to export a CSV file with column headers in the first line, as this kind of export/import operations is one of the most basic type of operations in data analysis.

Reproducible: Always

Steps to Reproduce:
COPY mytable 
INTO '/home/myfile.csv' 
USING DELIMITERS '|', '\n', '"' NULL AS '' HEADER;
Actual Results:  
None, as HEADER is not implemented

Expected Results:  
A delimited file with column headers that could be imported in some statistical application for data analysis
Comment 1 Sjoerd Mullender cwiconfidential 2019-10-03 17:15:48 CEST
There is something like this if you use mclient to export the data.
mclient -fcsv+, -d$database -s'select * from mytable' > myfile.csv

See the mclient manual [1].

[1] https://www.monetdb.org/Documentation/mclient-man-page
Comment 2 Sjoerd Mullender cwiconfidential 2019-10-03 17:16:48 CEST
I forgot to mention, you can use --null= to get the equivalent of NULL AS ''.