Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Converting a *.txt document to a comma delimited file

Posted on 2011-09-07
4
534 Views
Last Modified: 2012-05-12
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
Comment
Question by:wnbtechnology
  • 2
4 Comments
 
LVL 16

Expert Comment

by:Bryan Butler
ID: 36497127
Can you give an example of the results you want?  Something like this?

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

0
 

Expert Comment

by:rab59718
ID: 36497495
I would import it to Excel and then save as CSV
0
 

Author Comment

by:wnbtechnology
ID: 36497583
developedtester, you are correct that is the type of result that I would like to ouput to a comma delimitied file.
0
 
LVL 16

Accepted Solution

by:
Bryan Butler earned 125 total points
ID: 36497952
gc c:\FileWithEmptyLines.txt | where {$_ -ne ""} | %{$_ -replace "=",","} > newfile.txt

0

Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to sign a powershell script so you can prevent tampering, and only allow users to run authorised Powershell scripts
A brief introduction to what I consider to be the best editor for PowerShell.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question