Remove comma inside of double quotes

  • Bruin

    Ten Centuries

    Points: 1012

    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.

  • frederico_fonseca

    SSChampion

    Points: 14708

    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.

  • Bruin

    Ten Centuries

    Points: 1012

    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.

     

  • frederico_fonseca

    SSChampion

    Points: 14708

    it does help to read the manual

     

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

  • Bruin

    Ten Centuries

    Points: 1012

    Thanks I have it working.

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

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