Is Texpipe able to do that ?

Get help with installation and running here.

Moderators: DataMystic Support, Moderators

LDMGroup
Posts: 3
Joined: Fri Apr 18, 2008 6:04 pm

Is Texpipe able to do that ?

Postby LDMGroup » Fri Apr 18, 2008 6:59 pm

I'm evaluating Textpipe, I've different text files, each text file is like that

Text1.txt
Name:Alfred
Surname:Brown
City:London
CarType:Ford
CarModel:Mustang

Text2.txt
Name:Bob
Surname:White
CarType:Mercedes

Text3.txt
Name:Lisa
City:Manchester
CarType:BMW
CartModel:320 Convertible

Using the demo I managed to get this output on each line:

Code: Select all

Alfred\tBrown\tLondon\tFord\tMustang\r\n
Bob\tWhite\tMercedes\r\n
Lisa\tManchester\tBMW\t320 Convertible\r\n


What I would like to get as result is:

Code: Select all

Alfred\tBrown\tLondon\tFord\tMustang\r\n
Bob\tWhite\t\tMercedes\t\r\n
Lisa\t\tManchester\tBMW\t320 Convertible\r\n


So I get the same type of field on the same column, how I can do that with Textpipe ?

User avatar
DataMystic Support
Site Admin
Posts: 2138
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Re: Is Texpipe able to do that ?

Postby DataMystic Support » Mon Apr 21, 2008 2:43 pm

Hi there,

You need to use optional fields in a pattern match to allow for the missing fields. Which fields are always present and which ones are optional?
Regards,

Simon Carter, http://DataMystic.com/forums/index.php
http://PredictBGL.com - Insulin dose calculator for Type 1 diabetes
http://DownloadPipe.com - 250,000 free software downloads
http://DetachPipe.com - send huge email attachments

LDMGroup
Posts: 3
Joined: Fri Apr 18, 2008 6:04 pm

Re: Is Texpipe able to do that ?

Postby LDMGroup » Tue Apr 22, 2008 2:21 am

What do you mean with optional fields ? Name and CarType fields are always present Surname, City, CarModel are optional.
Thank you

User avatar
DataMystic Support
Site Admin
Posts: 2138
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Re: Is Texpipe able to do that ?

Postby DataMystic Support » Tue Apr 22, 2008 8:26 am

For example, an EasyPattern search/replace

[ 'Name:', capture( 1+ not cr or lf) as 'Name', cr, lf,
optional( 'Surname:', capture( 1+ not cr or lf) as 'Surname', cr, lf ),
optional( 'City:', capture( 1+ not cr or lf) as 'City', cr , lf ),
'CarType:', capture( 1+ not cr or lf) as 'CarType', cr, lf,
longest optional( 'CarModel:', capture( 1+ not cr or lf) as 'CarModel' ) ]

Replace with:

@Name,@Surname, @City, @CarType, @CarModel
Regards,

Simon Carter, http://DataMystic.com/forums/index.php
http://PredictBGL.com - Insulin dose calculator for Type 1 diabetes
http://DownloadPipe.com - 250,000 free software downloads
http://DetachPipe.com - send huge email attachments

LDMGroup
Posts: 3
Joined: Fri Apr 18, 2008 6:04 pm

Re: Is Texpipe able to do that ?

Postby LDMGroup » Tue Apr 22, 2008 9:23 pm

It works, thank you Simon!


Return to “TextPipe Tips and Tricks, Questions and Support”

Who is online

Users browsing this forum: No registered users and 3 guests