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

twig - Using Twigbridge in a Laravel 5.1 Package -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -

jdbc - Not able to establish database connection in eclipse -