Solved

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

Posted on 2006-06-19
6
369 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

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…
This is an explanation of a simple data model to help parse a JSON feed
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
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…

770 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