"be consistent" | |
PerlMonks |
Re^3: Help Sorting a CSV Fileby erix (Prior) |
on Oct 07, 2019 at 14:20 UTC ( [id://11107135]=note: 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 Section
Seekers of Perl Wisdom
|
|