Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Data Parsing - Removing a string and replacing it with a carriage return

Posted on 2006-06-19
6
Medium Priority
?
405 Views
Last Modified: 2010-04-17
I have a document with approximately 4,000 email addresses that need to be parsed into a single column by having the ";" (semicolon) string removed and replaced with a carriage return. Can anyone recommend a PERL or VBA snippet that can do this in fairly short order. Maybe theres an advanced text editor that someone could recommend that could do the same.

INPUT STRING

blahblah1@parsemeplease.com; blahblah2@parsemeplease.com; blahblah3@parsemeplease.com; blahblah3@parsemeplease.com;

DESIRED OUTPUT

blahblah1@parsemeplease.com
blahblah2@parsemeplease.com
blahblah3@parsemeplease.com
blahblah3@parsemeplease.com

Any help is greatly appreciated :)
0
Comment
Question by:nanohurtz
6 Comments
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 16936848
MyNewString = Replace(MyString, ";", vbCR)
0
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 2000 total points
ID: 16936864
In Word,
Find: ;
Replace; ^p
0
 
LVL 3

Expert Comment

by:pweegar
ID: 16936883
I like textpad.  Simply do a search for ;  (colon space if you have spaces after the colon). Replace with \n.  It's fast!
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 16937092
Using a VBScript (.vbs) file:

Option Explicit

Const ForReading = 1, ForWriting = 2

Dim fileName, fso, f, lines

fileName = "c:\someFile.txt"

Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists(fileName) Then
   Set f = fso.OpenTextFile(fileName, ForReading, False)
   If Not f.AtEndOfStream Then
      lines = f.ReadAll
      f.Close

      lines = Replace(lines, "; ", vbCrLf)

      Set f = fso.OpenTextFile(fileName, ForWriting, True)
      f.Write(lines)  
      f.Close
 
      MsgBox fileName, vbOKOnly, "Changes Made"
   Else
      MsgBox fileName, vbOKOnly, "File Is Empty"
   End If
Else
   MsgBox fileName, vbOKOnly, "File Not Found"
End If
0
 

Author Comment

by:nanohurtz
ID: 16937125
...and there you have it, a solution right under my nose and no need for scripting. Thanks a million Graham.
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 16938034
Thanks nanohurtz.

Don't feel bad. The answer is always obvious afterwards. It took me two goes.

cheers, graham
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Progress
Loops Section Overview

824 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