Bird
0
0

You have a CSV file with duplicate headers. What happens when you run Import-Csv on it?

hard📝 Application Q9 of 15
PowerShell - File and Directory Operations
You have a CSV file with duplicate headers. What happens when you run Import-Csv on it?
AImport-Csv throws a syntax error
BImport-Csv merges duplicate columns into one
CAll columns are imported with unique property names
DOnly the last column with the duplicate header is kept
Step-by-Step Solution
Solution:
  1. Step 1: Understand Import-Csv behavior with duplicate headers

    Import-Csv uses headers as property names; duplicates overwrite previous ones.
  2. Step 2: Result of duplicates

    Only the last column with the duplicate header remains accessible as a property.
  3. Final Answer:

    Only the last column with the duplicate header is kept -> Option D
  4. Quick Check:

    Duplicate headers cause last column to overwrite [OK]
Quick Trick: Duplicate headers overwrite earlier columns in Import-Csv [OK]
Common Mistakes:
  • Expecting error on duplicates
  • Thinking columns get renamed automatically
  • Assuming columns merge

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes