Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 551
  • Last Modified:

Converting a *.txt document to a comma delimited file

Good afternoon,
    I'm currently outputting a text document using powershell select-string; however, I need to some how convert the *.txt document to a comma delmitied file.  Below is an example:

Within the *.txt document that I'm outputting its looks like the following:

Sample1=Sample1
Sample2=Sample2


Sample3=Sample3
Sample4=Sample4

It does include 2 returns in between each section.  I would like to take this data and create a csv file that is comma delimited.  
0
wnbtechnology
Asked:
wnbtechnology
  • 2
1 Solution
 
Bryan ButlerCommented:
Can you give an example of the results you want?  Something like this?

Sample1,Sample1
Sample2,Sample2
Sample3,Sample3
Sample4,Sample4

0
 
rab59718Commented:
I would import it to Excel and then save as CSV
0
 
wnbtechnologyAuthor Commented:
developedtester, you are correct that is the type of result that I would like to ouput to a comma delimitied file.
0
 
Bryan ButlerCommented:
gc c:\FileWithEmptyLines.txt | where {$_ -ne ""} | %{$_ -replace "=",","} > newfile.txt

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Worried about phishing attacks?

90% of attacks start with a phish. It’s critical that IT admins and MSSPs have the right security in place to protect their end users from these phishing attacks. Check out our latest feature brief for tips and tricks to keep your employees off a hackers line!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now