Taking a list from notepad and turning it into a CSV

This procedure reads a list that is written in notepad and turns the list into a CSV.

First create a list in notepad. There a many ways to do this you could copy something from Excel sometimes PowerShell and other utilities returns date in a way that is hard to use. Some of the ESX reports come to mind. Useful information but not in a form you can do anything with.

This is a list of colours I created in Notepad I am going to turn this into a CSV.

Screen Shot 2014-11-06 at 12.04.07 pm

First import them into PowerShell and Assign them to a variable

$colours = Get-Content “C:\Users\Administrator\Documents\colours.txt”

This take the contents of colours.txt and assigns it to the variable $colours

$coloursCSV = $colours -join ‘,’

$colours -join ‘,’ takes the contents of $colours and puts a ‘,’ in between the values

 

Screen Shot 2014-11-06 at 12.11.25 pm

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *