- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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 edit the CSV file using PowerShell?
To edit the CSV file using PowerShell, you need to use the below commands.
We already have the CSV file output.csv, we will import this file first.
$csvfile = Import-csv C:\temp\Outfile.csv
Output
Below is the output of the CSV file.
EMP_Name EMP_ID CITY -------- ------ ---- Charles 2000 New York James 2500 Scotland Charles 3000 Poland
We need to update the above file. We will change the CITY of the EMP_ID ‘3000’ to MUMBAI. If we update the CITY name by the EMP_Name, it will update two rows as there two Charles, therefore we will use the EMP_ID token here.
Example
$csv |foreach{if($_.Emp_ID -eq "3000"){$_.City = "Mumbai"}} $csv |Export-Csv $outfile
Output
EMP_Name EMP_ID CITY -------- ------ ---- Charles 2000 New York James 2500 Scotland Charles 3000 Mumbai
- Related Articles
- How to convert JSON file to CSV file using PowerShell?
- How to retrieve CSV file headers using PowerShell?
- How to convert JSON to CSV file using PowerShell?
- How to append data into a CSV file using PowerShell?
- How to create a CSV file manually in PowerShell?
- 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 to create dynamic columns (headers) in CSV using PowerShell?
- How to read data from *.CSV file using JavaScript?
- How to search in the file using PowerShell?
- How to mount the ISO file using PowerShell?
- How to dismount the ISO file using PowerShell?
- How to get the file extension using PowerShell?
- How to install the MSI file using PowerShell?

Advertisements