READ_CSV Function

Reads a CSV file line-by-line and returns it in a table.

This table-valued function is used in the FROM clause of a SELECT statement and can participate in joins as if it were a table. However, it cannot be used in a CREATE TRIGGER statement. Internally, the READ_CSV function is translated into an IMPORT CSV statement that runs prior to the statement that contains the READ_CSV call.

Syntax

READ_CSV(file-path[has-header-row], [skip-lines], [file-encoding])

Parameters

Return Value

A table with columns defined by the input file.

Example

-- Returns a table containing the first 50 rows in
-- "file.csv", with column names taken from the first line.
SELECT * FROM READ_CSV('C:\file.csv') LIMIT 50;

-- Returns a table containing the contents of "ShiftJIS.csv",
-- which is read using the Japanese Shift-JIS encoding (code
-- page 932).
SELECT * FROM READ_CSV('C:\ShiftJIS.csv', 1, 0, 932);