- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to append data into a CSV file using PowerShell?
To append the data into CSV file you need to use –Append parameter while exporting to the CSV file.
In the below example, we have created a CSV file
Example
$outfile = "C:\temp\Outfile.csv" $newcsv = {} | Select "EMP_Name","EMP_ID","CITY" | Export-Csv $outfile $csvfile = Import-Csv $outfile $csvfile.Emp_Name = "Charles" $csvfile.EMP_ID = "2000" $csvfile.CITY = "New York" $csvfile | Export-CSV $outfile Import-Csv $outfile
Now we need to append the below data to the existing file. So first we will import the csv file into a variable called $csvfile
$csvfile = Import-Csv $outfile $csvfile.Emp_Name = "James" $csvfile.EMP_ID = "2500" $csvfile.CITY = "Scotland"
Once data is inserted into a variable, we will append data with –Append parameter.
$csvfile | Export-CSV $outfile –Append
Check the output:
Import-Csv $outfile
Output
EMP_Name EMP_ID CITY -------- ------ ---- Charles 2000 New York James 2500 Scotland
- Related Articles
- How to convert JSON file to CSV file using PowerShell?
- How to edit the CSV file using PowerShell?
- How to retrieve CSV file headers using PowerShell?
- How to convert JSON to CSV file using PowerShell?
- How to create a CSV file manually in PowerShell?
- How to read data from *.CSV file using JavaScript?
- How can we import data from .CSV file into MySQL table?
- How to append data to a file in Java?
- Importing / Exporting CSV file in PowerShell
- How to Export and import CSV file manually in PowerShell?
- How to parse a CSV file using PHP
- How can we export all the data from MySQL table into a CSV file?
- How to write data to .csv file in Java?
- How to read data from .csv file in Java?
- Writing data from database to .csv file

Advertisements