PostgreSQL File Text Array FDW
C Makefile
Permalink
Failed to load latest commit information.
data
expected
input
output adjust for new error message Mar 7, 2015
sql
.gitignore
META.json
Makefile Use right pgxs target for sql file May 15, 2013
README.md Fix typos. Mar 8, 2012
file_textarray_fdw.c update for upsteam API changes Sep 7, 2016
file_textarray_fdw.control bump version Mar 8, 2012
file_textarray_fdw.sql Generate versioned file. Mar 8, 2012

README.md

File Text Array Foreign Data Wrapper for PostgreSQL

This FDW is similar to the provided file_fdw, except that instead of the foreign table having named fields to match the fields in the data file, it should have a single field of type text[]. The parsed fields will be stashed in the array. This is useful if you don't know how many fields are in the file, or if the number can vary from line to line. Unlike standard COPY files and the file_fdw module, this module doesn't care how many fields there are - however many it finds on each line will be put into the array.

Example of use:

-- only needs to be done once
CREATE EXTENSION file_textarray_fdw;

-- usually only needs to be done once
CREATE SERVER file_server FOREIGN DATA WRAPPER file_textarray_fdw;

CREATE FOREIGN TABLE agg_csv_array (
       t text[]
) 
  SERVER file_server
  OPTIONS (format 'csv', 
           filename '/path/to/agg.csv', 
           header 'true', 
           delimiter ';', 
           quote '@', 
           escape '"', 
           null '');

SELECT t[1]::int2 AS a, 
       t[2]::float4 AS b
FROM agg_csv_array;