|Problems? Is your data what you think it is?|
Re: Module for intelligently analyzing and merging spreadsheet databy erix (Parson)
|on Feb 10, 2019 at 21:39 UTC||Need Help??|
PostgreSQL has (as a contrib module) file_fdw (fdw=Foreign Data Wrapper) which reads csv (readonly; it cannot write to the csv file). It offers the postgres SQL-interface to address the data in the text files.
1) Installing the file_fdw module ('create extension file_fdw') (once)
2) Creating a server  ('create server if not exists csvserver foreign data wrapper file_fdw') (once)
3) Construct a CREATE FOREIGN TABLE statement  to reflect the structure of the csv file. The csv-file header line can often be used to convert into such an CREATE statement (possibly even adding the data type to columns).
SQL calls to such a 'Foreign Table' now read the underlying csv file(s) (select * from mytable).
Advantages: SQL access to csv data.
Disadvantages: Needs Postgres. Readonly. No indexing possible, so that huge csv-files can make it slow (alhough 'copying' onto a materialized view  on the foreign table makes indexing possible). Filesystem access for the postgres superuser is necessary .
 Create Server