Wednesday, August 26, 2009

Correcting malformed csv

I have a .csv file created by a semi-brain dead application that didn't properly escape quote characters within the fields. I've been trying to come up with a way to replace one quote character with the proper two quote characters within the quoted fields, but haven't yet struck upon the magic sequence. 

As an example, the line

"ID",""Brief" Description","State","Assigned User",""Detailed" Description",

(Note  the quotes around "Brief" and "Detailed".)

needs to be changed into 

"ID","""Brief"" Description","State","Assigned User","""Detailed"" Description",

(Note, each of the " characters within the fields is transformed into "".)

Can anybody suggest a way to do this?

  -- Jay



--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

No comments: