Is Texpipe able to do that ?

Get help with installation and running here.

Moderators: DataMystic Support, Moderators, DataMystic Support, Moderators, DataMystic Support, Moderators

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

Is Texpipe able to do that ?

Post by LDMGroup »

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: 2227
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Re: Is Texpipe able to do that ?

Post by DataMystic Support »

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?
LDMGroup
Posts: 3
Joined: Fri Apr 18, 2008 6:04 pm

Re: Is Texpipe able to do that ?

Post by LDMGroup »

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: 2227
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Re: Is Texpipe able to do that ?

Post by DataMystic Support »

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
LDMGroup
Posts: 3
Joined: Fri Apr 18, 2008 6:04 pm

Re: Is Texpipe able to do that ?

Post by LDMGroup »

It works, thank you Simon!
Post Reply