Re: Using copy with a file containing blank rows

From: "George Weaver" <gweaver(at)shaw(dot)ca>
To: "Adrian Klaver" <adrian(dot)klaver(at)gmail(dot)com>
Cc: "pgsql-general" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Using copy with a file containing blank rows
Date: 2012-04-25 18:39:44
Message-ID: 4C295C8AE31C4909A2C7F8212199E931@D420
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


>----- Original Message -----
>From: Adrian Klaver

>On 03/15/2012 09:17 AM, George Weaver wrote:
>> Hi All,
>>
>> I am trying to use COPY to import postgresql logs into a postgresql
>> database for further review and sorting.

>Are you using the CSV format to log to the Postgres log?:
>http://www.postgresql.org/docs/9.1/interactive/runtime-config-logging.html#RUNTIME-CONFIG-LOGGING-CSVLOG

[life intervenes...]

Thanks Adrian - I wasn't using the CSV format - I am now! It solves the
blank line problem I was encountering.

George

>>
>> The problem I'm encountering happens when COPY hits a blank row:
>>
>> development=# COPY log
>> development-# FROM
>> 'D:/PostgreSQL/9.1/pg_log/postgresql-2012-03-15_093730.log'
>> development-# WITH DELIMITER '^' NULL AS '';
>>
>> ERROR: missing data for column "ip_address"
>> CONTEXT: COPY log, line 2: " "
>>
>> Line 2 is a blank line.
>>
>> Is there any way to use COPY with blank lines or do the blank lines have
>> to removed before using COPY?

>AFAIK, you have to remove blank lines.

>>
>> Thanks,
>> George
>>

--
Adrian Klaver
adrian(dot)klaver(at)gmail(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ben Chobot 2012-04-25 19:12:37 Re: Updates, ShareLocks, RowExclusiveLocks, and deadlocks
Previous Message Tom Lane 2012-04-25 18:35:18 Re: Updates, ShareLocks, RowExclusiveLocks, and deadlocks