There's more than one way to do things | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
I agree. However, there is a another step in-between text and database, in the form of a "Foreign Data Wrapper", to let the database serve up the underlying (csv-)textfile:
Results are (again):
Such SQL using a 'Foreign Table' reads the underlying csv/text file(s). The annoying part is setting up the table , for instance in the case of tables with hundreds of columns you need a separate little application to do that, and this is where perl comes in handy (reading the header line and turning it into the CREATE TABLE column-list). Weaknesses and strengths: Advantages: SQL access to csv data. DBD::CSV delivers SQL as in SQL::Statement::Syntax which is nice but basic. The Data Wrapper's Foreign Table gives you access to the data via the full postgres SQL engine: Window Functions, Grouping Sets/Cube/Rollup, Generated Columns, Partitioning , etc., etc.) Disadvantages: Needs Postgres, and with extension file_fdw installed. Table remains read-only. No indexing possible, so that huge csv-files can make it slow (alhough 'copying' onto a materialized view [3] on the foreign table makes of course indexing possible again). Filesystem access for the postgres superuser is necessary. It all depends what you want to do. [1] file_fdw - this foreign data wrapper reads text files [2] Create Server In reply to Re^3: Help Sorting a CSV File
by erix
|
|