Dean Matthews <[EMAIL PROTECTED]> sez: >I need to convert a CSV file to delimited. > >There are commas that should not be converted i.e. "Joe Smith, Phd" > >These commas are enclosed in quotes as above. > >How can I replace the commas with tabs without affecting the commas >enclosed in quotes? >
Probably the easiest way to handle this for arbitrary data is to make multiple search & replace passes (or roll them up into a text factory): one pass to locate and remap the commas within quoted fields, a second pass to replace the field-separator commas, and a final pass to unroll step 1. However, as other folks have alluded, the content may permit you to take shortcuts. For instance, if there's always at least one space preceding/following a comma within a field value but never any between fields[*], you can just do this: search for: ([^ ]),([^ ]) replace with: \1\t\2 (* in CSV, although leading and trailing spaces around the field separator are allowable, many apps don't generate same; if the app you used does not, that'll make life a bit easier. :-) Regards, Patrick Woolsey == Bare Bones Software, Inc. <http://www.barebones.com> P.O. Box 1048, Bedford, MA 01730-1048 -- ------------------------------------------------------------------ Have a feature request? Not sure the software's working correctly? If so, please send mail to <[EMAIL PROTECTED]>, not to the list. List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml> List archives: <http://www.listsearch.com/BBEditTalk.lasso> To unsubscribe, send mail to: <[EMAIL PROTECTED]>
