2018-05-14 19:58:49 +00:00
|
|
|
<a name="table_functions-file"></a>
|
|
|
|
|
|
|
|
# file
|
|
|
|
|
2018-09-06 18:15:16 +00:00
|
|
|
`file(path, format, structure)` - returns a table created from a path file with a format type, with columns specified in structure.
|
2018-05-14 19:58:49 +00:00
|
|
|
|
2018-09-06 18:15:16 +00:00
|
|
|
path - a relative path to a file from [user_files_path](../../operations/server_settings/settings.md#user_files_path).
|
2018-05-14 19:58:49 +00:00
|
|
|
|
2018-09-06 18:15:16 +00:00
|
|
|
format - file [format](../../interfaces/formats.md#formats).
|
2018-05-14 19:58:49 +00:00
|
|
|
|
2018-09-06 18:15:16 +00:00
|
|
|
structure - table structure in 'UserID UInt64, URL String' format. Determines column names and types.
|
2018-05-14 19:58:49 +00:00
|
|
|
|
|
|
|
**Example**
|
|
|
|
|
2018-10-16 09:41:29 +00:00
|
|
|
``` sql
|
2018-09-06 18:15:16 +00:00
|
|
|
-- getting the first 10 lines of a table that contains 3 columns of UInt32 type from a CSV file
|
|
|
|
SELECT * FROM file('test.csv', 'CSV', 'column1 UInt32, column2 UInt32, column3 UInt32') LIMIT 10
|
2018-05-14 19:58:49 +00:00
|
|
|
```
|
2018-10-16 09:10:07 +00:00
|
|
|
|
|
|
|
[Original article](https://clickhouse.yandex/docs/en/query_language/table_functions/file/) <!--hide-->
|