Dealing with double quotes in CSV

  • I have a fairly standard flat file to import, it is comma delimited, there are no text qualifiers like double quotes. However, some rows (about 1200 of the 75k) have double quotes in the data. Here are a couple of examples...

    This is what a good row would be like...

    Client Co,6671020740,(GMT+00:00) London,Global Account,UK Campaign,test keyword,1,0,£0.00,3.0

    This row gets caught in the error output redirection...

    Client Co,6671020740,(GMT+00:00) London,Global Account,UK Campaign,"another keyword",1,0,£0.00,3.0

    The quotes in the CSV are not all in the same column either. How should I deal with this?

    TIA!

    -----------------------------------------------
    SQL Server posts at my blog, Grapefruitmoon.Net[/url]

  • Are you sure there isn't something else going on causing that row to fail?

    You could simply modify your flat file source by telling it to use the double quote for the text qualifier.

  • I'm not certain that it's not something else causing the error, but I've narrowed it down to the quotes so far. Every one of the rows in the error output is a row with quotes somewhere...none with quotes get past the Flat File Destination stage.

    Unfortunately I have no control over the flat file itself, it's an automated extract from a third party.

    -----------------------------------------------
    SQL Server posts at my blog, Grapefruitmoon.Net[/url]

  • Modify the flat file source in the Connection Manager in your SSIS package. Tell it to use a double quote as the text qualifier.

  • open the file with excel. make any change and save. Excel will add quotes as necessary. At least all rows will be consistent.

  • Erik Kutzler (12/10/2008)


    Modify the flat file source in the Connection Manager in your SSIS package. Tell it to use a double quote as the text qualifier.

    That appears to have done the trick! Thank you sir. For some reason I had it in my head that that wouldn't work.

    Now onto my next issue...:)

    Cheers!

    -----------------------------------------------
    SQL Server posts at my blog, Grapefruitmoon.Net[/url]

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply