Solved

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

Posted on 2006-06-19
6
379 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 500 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 85

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

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