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
It was first tested with A Fast CSV Reader
- http://stackoverflow.com/questions/2081418/parsing-csv-files-in-c-sharp
http://www.codeproject.com/KB/database/CsvReader.aspx
Then we made a custom utility using String.Split method with the usual Foreach loop going through the array
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 id,pdate,itemname,qty from stock_apals order by pdate,id()",,,,,,,,"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
Is there a utility or a Regex that can find malformed columns are place quotes
This is especially with respect to performace, becuase these Logs are very long and
new ones are made almost every hour
I just want to update the columns and use the FastCSVReader to parse it.
Thanks for any advice and help