1

I have a powershell script to parse a CSV file and add a new value to specific header. For Example Input file is a header and i want to replace the value under it. I have added the logic and it works for normal hearder but as this header has a space i am not able to manage it. Can you please help me how can i manage the space

Convert into CSV

Import-CSV $CSV_File | ForEach-Object {
{$_.Input file} = "$machine_path\file"
{$_.Output file} ="$machine_path\Output"
$_ |  Export-Csv $machine_path\new.csv -NoTypeInformation
}

1 Answer 1

1

If you want to dereference a property with spaces in the name, use quotation marks:

Import-CSV $CSV_File | ForEach-Object {
  $_.'Input file' = "$machine_path\file"
  $_.'Output file' = "$machine_path\Output"
  $_ 
}| Export-Csv $machine_path\new.csv -NoTypeInformation
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.