Remove comma inside of double quotes

  • I have a file comma delimited that has no header. How can I clean the extra comma inside of my double quotes?

    It sees that comma and adds and extra field to my output. This is a short example data, my file has 37 columns and have found it in

    2 fields for now, but could be in any one of the 37 columns

    example:

    data1,"carrier,extra" ,fileload

    Thanks.

  • no need to do it - that comma is part of the data and unless you have a business rule that requires its removal you should leave it in.

    In posh if you use import-csv and assuming the file is correctly built, it will deal with that comma correctly as, at least on the sample you supplied, correctly "escape'd" by the 2 double quotes surrounding that column.

    Fact that the file has no headers means nothing - you can still use import-csv by using the headers option.

  • Can I self generate the headers and only retrieve the fields I need which the one with a comma within double quotes

    isn't needed.

    example of the header generation ..

    Thanks.

     

  • it does help to read the manual

     

    $A = Import-Csv -Path .\file.csv -Header 'column1', 'column2', 'column3'|select column1,column3

  • Thanks I have it working.

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

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