Newbie needs help..

Get help with installation and running here.

Moderators: DataMystic Support, Moderators

rukiddin
Posts: 6
Joined: Wed Sep 23, 2009 9:40 am

Newbie needs help..

Postby rukiddin » Wed Sep 23, 2009 9:51 am

This should be an easy one. I'm not a programmer, so I've been hacking my way through TextPipe and just need a little help to finish up.

What I've got is an old school item status report that details about 30-40 items. Each item has roughly 20 lines of information. I only need to extract 4 of the lines for my purposes. I can easily write a filter to extract each of the 4 lines separately, but I haven't been able to figure out how to extract all 4 of the lines into one output file. Ideally, I would then like to take the 4 lines of output per item and put them on one single line, so I would end up with the detail I need for the 30-40 products in a file that has only 30-40 lines. (which will make it very easy to import into Excel)

I'm using "Extract lines matching perl pattern [using 1 line of each text below]"

^\w{2}\d{4}
^TTL
OPEN RMA
^\|TOT

If I run this 4 times (once for each line of text), I get 4 files which I can easily merge together, but I figure I should be able to run this just once and get the output I need.

At the end, I want to take the output and combine each output onto 1 line for each product so that I end up with a 30-40 line output. (I know that would involve a search and replace of some sort)

Any help would be appreciated.

Thanks

Mike

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

Re: Newbie needs help..

Postby DataMystic Support » Wed Sep 23, 2009 4:20 pm

Several approaches Mike.

You could first REMOVE non-matching lines, using
Filters\Remove\Remove lines\Remove non-matching lines

Then you'd just be left with what you want. Let me know if this helps.
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

rukiddin
Posts: 6
Joined: Wed Sep 23, 2009 9:40 am

Re: Newbie needs help..

Postby rukiddin » Wed Sep 23, 2009 11:58 pm

It's easier to identify the lines I want to keep, only because they are always there.. Most of the other lines are more repetitive, and not as easy to uniquely identify. I will give that another try though.

rukiddin
Posts: 6
Joined: Wed Sep 23, 2009 9:40 am

Re: Newbie needs help..

Postby rukiddin » Thu Sep 24, 2009 2:43 am

Ok, I figured it out using the Remove non-matching lines filter. Thanks for that. Now I need to figure out how to put each item's results on a single line (instead of 4 separate lines). I know that involves Search and Replace. The Syntax for the commands is a bit technical for me.. I know it goes something like

([^\r\n]*)\r\n([^\r\n]*?) <- Can someone translate this into English so I can better understand how it works?
Replace with
$1$2

I know \r is a carriage return, and \n is a newline, but I'm unable to actually read and understand what the above lines actually means. I need to modify it to work with 4 lines of output, vs. 2 lines.

Thanks

Mike

rukiddin
Posts: 6
Joined: Wed Sep 23, 2009 9:40 am

Re: Newbie needs help..

Postby rukiddin » Thu Sep 24, 2009 2:44 am

Also, to throw a curve ball.. one of the 4 lines isn't always there. The first three are always present, the 4th is more of a grand total from the report, so it shows up randomly after the 3rd line.

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

Re: Newbie needs help..

Postby DataMystic Support » Thu Sep 24, 2009 6:20 am

For clarity, try this EasyPattern,

[ capture( 0+ not cr or lf ), cr, lf,
capture( 0+ not cr or lf ), cr, lf,
capture( 0+ not cr or lf ), cr, lf,
capture( longest optional( 0+ not cr or lf ), cr, lf, )
]

Replace with
$1 $2 $3 $4\r\n
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

rukiddin
Posts: 6
Joined: Wed Sep 23, 2009 9:40 am

Re: Newbie needs help..

Postby rukiddin » Thu Sep 24, 2009 7:11 am

DataMystic Support wrote:For clarity, try this EasyPattern,

[ capture( 0+ not cr or lf ), cr, lf,
capture( 0+ not cr or lf ), cr, lf,
capture( 0+ not cr or lf ), cr, lf,
capture( longest optional( 0+ not cr or lf ), cr, lf, )
]

Replace with
$1 $2 $3 $4\r\n



If I only parse for the first 3 lines, and then use the above except for the 4th capture line it works PERFECT, however, if I add the 4th component, and the final capture, the output is screwed up. It has extra New lines, and seems to mess up the order of the other data. (Hard to explain.) Would it be because there is no reserved space for the 4th item when it's not there?

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

Re: Newbie needs help..

Postby DataMystic Support » Thu Sep 24, 2009 9:03 am

sorry, use

[ capture( 0+ not cr or lf ), cr, lf,
capture( 0+ not cr or lf ), cr, lf,
capture( 0+ not cr or lf ), cr, lf,
capture( longest optional( 0+ not cr or lf ) ), cr, lf,
]

The trailing CR/LF should not have been part of the capture.
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

rukiddin
Posts: 6
Joined: Wed Sep 23, 2009 9:40 am

Re: Newbie needs help..

Postby rukiddin » Fri Sep 25, 2009 10:17 am

DataMystic Support wrote:sorry, use

[ capture( 0+ not cr or lf ), cr, lf,
capture( 0+ not cr or lf ), cr, lf,
capture( 0+ not cr or lf ), cr, lf,
capture( longest optional( 0+ not cr or lf ) ), cr, lf,
]

The trailing CR/LF should not have been part of the capture.


That seems to have helped a little bit, but didn't solve the problem. It still seems to be inserting carriage returns, and the line I'm trying to add to the end of a line when it appears is still on it's own line.

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

Re: Newbie needs help..

Postby DataMystic Support » Fri Sep 25, 2009 5:07 pm

Ensure you don't have any trialing cr\lfs in the replace string - right-click and choose 'Show Special Characters'
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


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

Who is online

Users browsing this forum: Google [Bot], Yahoo [Bot] and 7 guests