powershell - How to append datatable to existing records in CSV file -


i have csv file myfile.csv. contains following data:

rollnumber  name  1           amol 2           ravi 

now fetching few records sql server follows:

rollnumber  name 3           viku 4           vaibhav 

i not able find way append these new records existing csv file. don't want repeat header again. don't have ms excel, want play csv. tried using add-content, didn't worked out.

since powershell v3 export-csv cmdlet has -append parameter allows appending existing csv.

$data | export-csv 'myfile.csv' -append -notype 

on earlier versions can work around converting data csv, skip header line, append output file using add-content or out-file -append:

$data | convertto-csv -notype | select -skip 1 | add-content 'myfile.csv' 

Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -