How to ignore blank lines with file_fdw - Mailing list pgsql-general

From Nicklas Avén
Subject How to ignore blank lines with file_fdw
Date
Msg-id 201404221145.s3MBjowO020132@mail2.space2u.com
Whole thread Raw
Responses Re: How to ignore blank lines with file_fdw  (Albe Laurenz <laurenz.albe@wien.gv.at>)
List pgsql-general
Hallo

I am struggling to find the best solution to ignore blank lines in csv-file when using file_fdw.

A blank line makes the table unreadable.

I would like to avoid manipulating the file directly and avoid the need to make a new corrected copy of the file.

I am on Linux so I have found a solution when using COPY:
COPY test_table from program 'sed ''/^ *$/d'' /opt/builds/inotify_test/test.csv'  with (format 'csv', header 'true');

but since the "program" option not seems to be implemented in file_fdw I am still searching for a solution.

I have also found in an email from 2011 
http://www.postgresql.org/message-id/4E699DE6.8010606@gmail.com

that when force_not_null was implemented in file_fdw the patch also included "some cosmetic changes such as removing useless blank lines."
But I do not find that blank lines is removed in general since I cannot read csv-files with blank lines, and I do not understand how the option "force_not_null" can do the trick since that is on the column level and not lines/row.

Any good ideas out there?

Thanks
Nicklas Avén

pgsql-general by date:

Previous
From: basti
Date:
Subject: Re: could not rename temporary statistics file "/run/shm/pgstat.tmp" to "/run/shm/pgstat.stat": No such file or directory
Next
From: Tim Kane
Date:
Subject: hstore binary representation of keys