PostgreSQL does this out of the box with :
CREATE EXTENSION file_fdw;
CREATE SERVER import FOREIGN DATA WRAPPER file_fdw;
CREATE FOREIGN TABLE foo (
col1 text,
col2 text,
...
) SERVER import
OPTIONS ( filename '/path/to/foo.csv', format 'csv' );
SELECT col1 FROM foo WHERE col2='x';