4 ms·
To quickly examine CSV data in PostgreSQL, you can do this: CREATE EXTENSION file_fdw; CREATE SERVER my_server FOREIGN DATA WRAPPER file_fdw; CREATE FO
by elchief 13y ago
To quickly examine CSV data in PostgreSQL, you can do this:
CREATE EXTENSION file_fdw;
CREATE SERVER my_server FOREIGN DATA WRAPPER file_fdw;
CREATE FOREIGN TABLE my_csv (
field_a text,
field_b smallint,
...
) SERVER my_server
OPTIONS ( filename 'some/file/path.csv', format 'csv', header 'true' );
select * from my_csv;
- eli 13y agoThe first python script I wrote is a fairly ugly hack that converts CSV to a SQLITE-compatible SQL so you can query it. https://github.com/elidickinson/csv-tools/blob/master/csv2sql.py https://github.com/elidickinson/csv-tools/blob/master/csv2sq...
- stevekemp 13y agoI once wrote a tool to insert Apache logfiles into a SQLite database to run queries against. I'm frequently surprised by how popular that project remains: * http://steve.org.uk/Software/asql
- eli 13y agoThat reminds me, there's actually a funky old Microsoft skunkworks project that lets you query CSVs and Apache logfiles and all sorts of stuff via SQL: http://www.microsoft.com/en-us/download/details.aspx?id=2465 http://www.microsoft.com/en-us/download/details.aspx?id=2465 I have no idea if it even still runs on current windows versions.