## Newbie needs help..

Get help with installation and running here.
rukiddin
Posts: 6
Joined: Wed Sep 23, 2009 9:40 am

### Newbie needs help..

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

### Re: Newbie needs help..

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, https://www.DataMystic.com
https://www.JadeDiabetes.com - Insulin dose calculator for Type 1 diabetes
rukiddin
Posts: 6
Joined: Wed Sep 23, 2009 9:40 am

### Re: Newbie needs help..

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..

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..

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.
DataMystic Support
Posts: 2229
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

### Re: Newbie needs help..

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, https://www.DataMystic.com
https://www.JadeDiabetes.com - Insulin dose calculator for Type 1 diabetes
rukiddin
Posts: 6
Joined: Wed Sep 23, 2009 9:40 am

### Re: Newbie needs help..

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?
DataMystic Support
Posts: 2229
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

### Re: Newbie needs help..

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, https://www.DataMystic.com
https://www.JadeDiabetes.com - Insulin dose calculator for Type 1 diabetes
rukiddin
Posts: 6
Joined: Wed Sep 23, 2009 9:40 am

### Re: Newbie needs help..

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.
DataMystic Support
Posts: 2229
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

### Re: Newbie needs help..

Ensure you don't have any trialing cr\lfs in the replace string - right-click and choose 'Show Special Characters'
Regards,

Simon Carter, https://www.DataMystic.com
https://www.JadeDiabetes.com - Insulin dose calculator for Type 1 diabetes