Challenge - 5 Problems
CSV Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
What is the output of this Import-Csv command?
Given a CSV file named
What will be the output of this PowerShell command?
data.csv with the following content:Id,Name,Age 1,Alice,30 2,Bob,25
What will be the output of this PowerShell command?
Import-Csv -Path 'data.csv' | ForEach-Object { $_.Name }PowerShell
Import-Csv -Path 'data.csv' | ForEach-Object { $_.Name }Attempts:
2 left
💡 Hint
Import-Csv reads the CSV and creates objects with properties matching the headers.
✗ Incorrect
Import-Csv reads each row as an object with properties Id, Name, and Age. The command selects the Name property, so it outputs the names 'Alice' and 'Bob'.
💻 Command Output
intermediate2:00remaining
What does this Export-Csv command produce?
Consider this PowerShell code:
What will be the content of
$data = @(
@{Id=1; Name='Alice'; Age=30},
@{Id=2; Name='Bob'; Age=25}
)
$data | Export-Csv -Path 'output.csv' -NoTypeInformationWhat will be the content of
output.csv?PowerShell
$data = @(@{Id=1; Name='Alice'; Age=30}, @{Id=2; Name='Bob'; Age=25})
$data | Export-Csv -Path 'output.csv' -NoTypeInformationAttempts:
2 left
💡 Hint
Export-Csv outputs CSV with quoted values by default and includes headers.
✗ Incorrect
Export-Csv creates a CSV file with headers and quotes around each field. The -NoTypeInformation flag omits the type info line.
🔧 Debug
advanced2:00remaining
Why does this Import-Csv command fail?
You run this command:
But you get an error:
Import-Csv : Cannot find path 'missing.csv' because it does not exist.
What is the cause?
Import-Csv -Path 'missing.csv'
But you get an error:
Import-Csv : Cannot find path 'missing.csv' because it does not exist.
What is the cause?
PowerShell
Import-Csv -Path 'missing.csv'Attempts:
2 left
💡 Hint
Check if the file path is correct and the file exists.
✗ Incorrect
The error means the file path is invalid or the file is missing. Import-Csv needs an existing file to read.
🚀 Application
advanced2:00remaining
How to filter CSV rows with Import-Csv and Export-Csv?
You have a CSV file
You want to create a new CSV
Which PowerShell command does this correctly?
users.csv with columns: Id, Name, Age.You want to create a new CSV
adults.csv containing only rows where Age is 18 or more.Which PowerShell command does this correctly?
Attempts:
2 left
💡 Hint
Use Where-Object to filter and Export-Csv with -NoTypeInformation to save.
✗ Incorrect
Option D correctly converts Age to int and filters rows with Age >= 18, then exports without type info.
🧠 Conceptual
expert2:00remaining
What is the effect of the -NoTypeInformation parameter in Export-Csv?
When using Export-Csv in PowerShell, what does the
-NoTypeInformation parameter do?Attempts:
2 left
💡 Hint
Check the first line of CSV files exported with and without this parameter.
✗ Incorrect
By default, Export-Csv adds a line with type info like '#TYPE System.Management.Automation.PSCustomObject'. -NoTypeInformation omits this line.