Creating CSV output from non CSV input

by Jan 13, 2016


Can someone please help me with the following question

If I have a single text file on disk  let call it C:tempMyFile.txt

the text file contains : separate data as follows


Name   : Fred
DOB     : 1/June/1970
Hobby  : Computers


Name   : Jane
DOB     : 3/July/1978
Hobby  : Reading



there are a couple of blank lines between each set of records as shown above (so you know where one set ends and another starts)

I want to covert the above to CSV (or PowerShell object I can then export the CSV) where the text before the : becomes the key (heading) and the itext after the : becomes the value

Name     DOB                Hobby
Fred       1/June/1970   Computers
Jane       3/July/1978    Reading


Thanks in advance