none
Add the same header again at end of a script RRS feed

  • Question

  • $getcsv = import-csv $filepath -Delimiter ";"

    -Header "$Enhet" ,"$Ledigt", "$Totalt" ,"$Nyttjat ", "$ram","Script startat vid","$Vem"

    |export-csv v:\logg.csv -NoTypeInformation

    If i run this part a second time it wont add the headers to the bottom row, how can i fix this


    • Edited by maltorp Wednesday, January 16, 2019 7:49 PM looked bad
    • Moved by Bill_Stewart Friday, March 15, 2019 5:40 PM Unanswerable drive-by question
    Wednesday, January 16, 2019 7:11 PM

All replies

  • start by writing the script correctly and also restructuring for clarity and easy of use.

    $header = $Enhet, $Ledigt, $Totalt, $Nyttjat, $ram, 'Script startat vid', $Vem
    import-csv $filepath -Delimiter ';' -Header $header
        export-csv v:\logg.csv -NoTypeInformation -Append

    The header only needs to be defined once.  The import can be run on many files and will not add extra headers.


    \_(ツ)_/

    Wednesday, January 16, 2019 7:40 PM
  • is there way to add new headers everytime?
    Wednesday, January 16, 2019 7:55 PM
  • What? Ad new headers in the middle of a CSV?  That is what you are already doing.

    If you are just trying concatenate the files then use append.


    \_(ツ)_/

    Wednesday, January 16, 2019 8:06 PM