Re: Help in Parsing PG log usings CSV format

From: Martin Gregorie <martin(at)gregorie(dot)org>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Help in Parsing PG log usings CSV format
Date: 2012-03-22 13:41:43
Message-ID: 1332423703.24108.86.camel@zappa.gregorie.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, 2012-03-22 at 09:32 +0000, Arvind Singh wrote:
> Help needed in parsing PostgreSQL CSV Log
> Hello friends,
> I am working an a section of application which needs to Parse CSV Logs generated by PostgreSql server.
> - The Logs are stored C:\Program Files\PostgreSQL\9.0\data\pg_log
> - The Server version in 9.0.4
> - The application is developed in C Sharp
> * The basic utility after Parse the Log is to show contents in a DataGridView.
> * There are other filter options like to view log contents for a particular range of Time for a Day.
>
> **However the main problem that is, the Log format is not readable**
>
>
> A Sample Log data line
> > 2012-03-21 11:59:20.640 IST,"postgres","stock_apals",3276,"localhost:1639",4f697540.ccc,10,"idle",2012-03-21 11:59:20 IST,2/163,0,LOG,00000,"statement: SELECT version()",,,,,,,,"exec_simple_query, .\src\backend\tcop\postgres.c:900",""
>
> As you can see the columns in the Log are comma separated , But however individual values are not Quote Enclosed.
>
> For instance the 1st,4rth,6th .. columns
>
>
Thats fairly standard. A good CSV parser only requires a field to be
quoted if it contains commas or quotes. In the latter case the internal
quotes should be doubled, i.e the three fields in the following:

unquoted field,"contains commas, etc.","Fred said ""Cool!""."

should be handled correctly by a decent CSV parser.

Martin

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Merlin Moncure 2012-03-22 14:46:31 Re: Large PostgreSQL servers
Previous Message Heiko Wundram 2012-03-22 12:55:47 Very high memory usage on restoring dump (with plain pqsl) on pg 9.1.2