none
Powershell change column data to title case RRS feed

  • Question

  • Hi Im having trouble manipulating some data in a CSV file

    As below I have a CSV file that has a header row and I need to change the data in the Title,State,Country columns to Title Caps and then save the updates but leave the other columns unchanged.

    Example Data:

    First Name,Surname,Email Address,Initials,Position No,Title,State,Country,Position Number,Second Name,Preferred Name,Gender,Position Start,Position End,Joined,Birth Date

    "0001","John","Smith","jsmith@email.com.au","","CUS003","MR","VIC","AUSTRALIA","Customer Service Agent","","","M",31 Mar 2018,

    Afterwards Id like the file to display like below:

    First Name,Surname,Email Address,Initials,Position No,Title,State,Country,Position Number,Second Name,Preferred Name,Gender,Position Start,Position End,Joined,Birth Date

    "0001","John","Smith","jsmith@email.com.au","","CUS003","Mr","Vic","Australia","Customer Service Agent","","","M",31 Mar 2018,

    Thanks in advance for any assistance.

    • Moved by Bill_Stewart Wednesday, May 30, 2018 7:50 PM Unanswerable drive-by question
    Tuesday, April 10, 2018 1:21 PM

All replies

  • Enumerate the CSV an change the columns in each row.

    $_.Title = [cultureinfo]::CurrentCulture.TextInfo.ToTitleCase($_.Title)

    Then export the CSV.


    \_(ツ)_/

    Tuesday, April 10, 2018 1:29 PM
  • thanks for the quick response, im new to powershelgl for data minipulation, and don't understand culture info,

    do you have a broader example of opening CSV, manipulating the data in the particular columns and saving to CSV ?

    Tuesday, April 10, 2018 1:38 PM
  • Have a look at Import-Csv and Export-Csv
    Tuesday, April 10, 2018 1:50 PM