Successfully added
PowerShell
by Patrik
Read Row by Row in a Loop from a CSV File using PowerShell
Assuming a CSV file as such:
Name, Address, City | |
name1, Address1, city1 | |
name2, Address2, city2 | |
name3, Address3, city3 |
We will use Import-Csv
to populate the objects from a CSV file. With $csv.Name
we will retrieve all cells in the Name column and pass this to the ForEach-Object
cmdlet to loop through each item. In this loop, we will just output the name.
$csv = Import-Csv "C:\File.csv" | |
$csv.Name | ForEach-Object { | |
Write-Output "The name is: $_" | |
} |
PowerShell
Referenced in:
Comments