Read and write NSV (Newline-Separated Values) files
Installing and Loading
INSTALL nsv FROM community;
LOAD nsv;
Example
-- Read an NSV file (type narrowing mimics CSV behaviour)
SELECT * FROM read_nsv('data.nsv');
-- Write query results as an NSV
COPY my_table TO 'output.nsv' (FORMAT nsv);
-- Read without type narrowing, i.e. everything is a string
SELECT * FROM read_nsv('data.nsv', all_varchar=true);
-- Read a headerless file
SELECT * FROM read_nsv('data.nsv', header=false);
-- Write without a header row
COPY my_table TO 'output.nsv' (FORMAT nsv, HEADER false);
About nsv
NSV is a plain text data format for sequences of sequences. A subset of these where the nested sequences all have the same length is of interest, for that is effectively a table.
The NSV format itself is type-agnostic. This extension attempts to closely follow what the CSV extension does for the type narrowing logic, the column name convention, and the interface surface. A subset of that, of course.
In terms of expressive power, NSV can be used for anything CSV is used for, but being a format much more amenable to parsing, the performance of that is far higher than for CSV, and so is its readability. This extension is intended to enable performant queries against the files using the format.
Added Functions
| function_name | function_type | description | comment | examples |
|---|---|---|---|---|
| read_nsv | table | NULL | NULL |
Overloaded Functions
| function_name | function_type | description | comment | examples | |—————|—————|————-|———|———-|
Added Types
| type_name | type_size | logical_type | type_category | internal | |———–|———-:|————–|—————|———-|
Added Settings
| name | description | input_type | scope | aliases | |——|————-|————|——-|———|