Why pretend? Assuming these two csv lines:
11,22,33,"ABC" 1111,3333,4444,"asdfasd asdfasdfasdf"
And assuming you have the file_fdw extension installed ( create extension file_fdw; ), you could have Pg query it via:
create server pgcsv foreign data wrapper file_fdw; create foreign table pgcsv ( col1 int, col2 int, col3 int, col4 text ) server pgcsv options ( filename '/tmp/pm-1040691.csv', format 'csv' ); select * from pgcsv; -- or a single column, of course...
which will output:
CREATE SERVER CREATE FOREIGN TABLE col1 | col2 | col3 | col4 ------+------+------+---------------------- 11 | 22 | 33 | ABC 1111 | 3333 | 4444 | asdfasd asdfasdfasdf
Obviously not the easiest way to go about it (and on top of that, postgres is rather picky about the text's precise format). I'm just showing this because you brought up "database" ;)
In reply to Re^2: Extract Column of CSV - pretend its a database.
by erix
in thread Extract a column of csv
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |