Re: COPY table_name (single_column) FROM 'iso-8859-1.txt' DELIMITER E'\n' - Mailing list pgsql-hackers

From Joel Jacobson
Subject Re: COPY table_name (single_column) FROM 'iso-8859-1.txt' DELIMITER E'\n'
Date
Msg-id 0e451c85-ce2c-4197-91aa-5eecd4f0d3e9@www.fastmail.com
Whole thread Raw
In response to Re: COPY table_name (single_column) FROM 'iso-8859-1.txt' DELIMITER E'\n'  ("Daniel Verite" <daniel@manitou-mail.org>)
List pgsql-hackers
What about:

   COPY ... FROM ... WITH PATTERN 'regexp_pattern'

Where the columns would be matched with the capture groups.

This could handle the quite common case of varying white-space as column separators:

   COPY log (col1, col2, col3) FROM 'log.txt' WITH PATTERN '^(\S+)\s+(\S+)\s+(\S+)$'

This could also handle $SUBJECT:

   COPY table_name (single_column) FROM 'unknown.txt' WITH PATTERN '^(.*)$';

And lots of other more complex use-cases.

/Joel

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Another modest proposal for reducing CLOBBER_CACHE_ALWAYS runtime
Next
From: Peter Smith
Date:
Subject: Re: AlterSubscription_refresh "wrconn" wrong variable?