CSVWithNamesAndTypes
Input | Output | Alias |
---|---|---|
✔ | ✔ |
Description
Also prints two header rows with column names and types, similar to TabSeparatedWithNamesAndTypes.
Example Usage
Inserting Data
Starting from version 23.1, ClickHouse will automatically detect headers in CSV files when using the CSV
format, so it is not necessary to use CSVWithNames
or CSVWithNamesAndTypes
.
Using the following CSV file, named as football_types.csv
:
Create a table:
Insert data using the CSVWithNamesAndTypes
format:
Reading Data
Read data using the CSVWithNamesAndTypes
format:
The output will be a CSV with a two header rows for column names and types:
Format Settings
If setting input_format_with_names_use_header is set to 1
,
the columns from input data will be mapped to the columns from the table by their names, columns with unknown names will be skipped if setting input_format_skip_unknown_fields is set to 1
.
Otherwise, the first row will be skipped.
If setting input_format_with_types_use_header is set to 1
,
the types from input data will be compared with the types of the corresponding columns from the table. Otherwise, the second row will be skipped.