Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Import-Csv Powershel basics

239 views

Published on

Import-Csv Powershel basics

Published in: Software
  • Be the first to comment

Import-Csv Powershel basics

  1. 1. Import-Csv Powershell Basics <# Sample CSV File data is given below Name,Status,Salary,Pay Basis,Position Title "Aberger, Marie E.",Employee,"$42,000.00",Per Annum,PRESS ASSISTANT Sample CSV File data end #> #Import-Csv File into memory. Entire file is in memory. Import-csv -Path "D:employee_data.csv" | Measure-Object | Select- Object Count #Import the file and assign it to variable $csvFile = Import-csv -Path "D:employee_data.csv" $csvFile | Select-Object -First 4 | Format-Table #First 4 rows $csvFile | Select-Object -Last 4 | Out-GridView #Last 4 rows $csvFile | Group-Object "Status“ | Out-GridView #group by status #group by “Position Title” $csvFile | Group-Object "Position Title“ | Out-GridView #group by “Position Title”, count greater than 5 $csvFile | Group-Object "Position Title" | where {$_.Count -gt 5}
  2. 2. Import-Csv Powershell Basics <# Sample CSV File data is given below Name,Status,Salary,Pay Basis,Position Title "Aberger, Marie E.",Employee,"$42,000.00",Per Annum,PRESS ASSISTANT Sample CSV File data end #> #Import the file and assign it to variable $csvFile = Import-csv -Path "D:employee_data.csv“ #Search for Name like *mar* $csvFile | where {$_.Name -like '*mar*'} | Out-GridView #Search for: Status=Employee and position = Press Assitant $csvFile | where {$_.Status -eq "Employee" -and $_."Position Title" -eq "PRESS ASSISTANT"} | Out-GridView #Total, minimum, maximum, average salary of first 5 employees $csvFile | Select-Object -First 5 |Select-Object -Property @{Name="Salary"; Expression = { $_.Salary -replace '[^0-9.]'}} | Measure-Object -Property Salary -minimum -maximum -average -sum #Total, minimum, maximum, average salary of All employees $csvFile | Select-Object -Property @{Name="Salary"; Expression = { $_.Salary -replace '[^0-9.]'}} | Measure-Object -Property Salary - minimum -maximum -average -sum

×