gavin
gavin

Reputation: 1

Splitting on column into multiple coloums from a CSV file in powershell

I am new to using powershell and I am in need of some assistance.

I have a csv file that looks like this:

DisplayName,AllJSSUSers,ALLMobileDevices,LimitToUsers,Exclusions,DepartmentEx,IconURL,ID 
Aurasma,TRUE,TRUE,"G_Year 4,G_Year 7,G_Year 11,G_Year 6,G_Year 10,G_Year 5,G_Year 9,G_Teaching Staff,G_Year 8,G_Supply Teachers,G_Year 3,G_Year 12",,,,5

What I would like to do is split the column "LimitToUsers" where the commas are into multiple column and then output that to a new csv file.

I have no idea where to start with this. Can anyone help?

Thank you

Gavin

Upvotes: 0

Views: 602

Answers (1)

Joey
Joey

Reputation: 354794

  • You can read CSV data with Import-Csv.
  • You can access that column from each data object by accessing the LimitToUsers property.
  • You can split a string with the -split operator.
  • You can add new properties to object with Add-Member.
  • You can write CSV with Export-Csv.

Since you somehow have to split a single column into multiple ones, how you do that is up to you and I can't help you there

Upvotes: 1

Related Questions