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

timeout - Handshake_timeout on RabbitMQ using python and pika from remote vm -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

c# - Search and Add Comment with OpenXML for Word -