add filler lines based on line contents

Get help with installation and running here.

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

Post Reply
alexgrainger
Posts: 5
Joined: Wed Dec 15, 2004 10:13 pm

add filler lines based on line contents

Post by alexgrainger »

Hi,

I am wondering if Textpipe is able to perform the following task. My data looks like the sample below. Every line has either "CODExxx" or "TAG" in the 5th Column. The data should always follow the pattern "CODExxx", "TAG","CODExxx", "TAG",....etc.

Where there are 2 "CODExxx" lines in a row, is it possible to insert a DUMMY "TAG" row? Also, where there are 2 "TAG" lines in a row, is it possible to insert a DUMMY "CODExxx" row?

1,0,09.07.04,18:20:12,CODE39,Len:6,002509
1,0,09.07.04,18:20:13,TAG,4002,0000000102E2803A,
1,0,09.07.04,18:20:16,CODE39,Len:6,002508
1,0,09.07.04,18:20:47,CODE39,Len:6,002508
1,0,09.07.04,18:20:47,TAG,4002,0000000102E28CA5,
1,0,09.07.04,18:20:50,CODE39,Len:6,002507
1,0,09.07.04,18:20:50,TAG,4002,0000000102E28AE6,
1,0,09.07.04,18:24:21,CODE128,Len:7,49841
1,0,09.07.04,18:24:25,TAG,4002,0000000102E27E4A,
1,0,13.07.04,11:29:24,CODE128,Len:7,97814
1,0,13.07.04,11:29:40,TAG,4002,0000000102DF0257,
1,0,13.07.04,11:29:40,TAG,4002,0000000102DF0257,
1,0,13.07.04,11:29:42,CODE128,Len:7,97815
1,0,13.07.04,11:29:43,TAG,4002,0000000102E390BC,
1,0,13.07.04,11:29:46,CODE128,Len:7,97816
1,0,13.07.04,11:29:52,TAG,4002,0000000102EF24A5,

Once we have produced the file cleaned with the above rules, could we then convert it so that every 2 lines are combined into 1 line.

e.g.
1,0,13.07.04,11:29:46,CODE128,Len:7,97816
1,0,13.07.04,11:29:52,TAG,4002,0000000102EF24A5,

BECOMES:

1,0,13.07.04,11:29:46,CODE128,Len:7,97816,1,0,13.07.04,11:29:52,TAG,4002,0000000102EF24A5,


Any help would be most appreciated.

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

Post by DataMystic Support »

Hi Alex,

You can do this easily with an EasyPattern find/replace:

Code: Select all

[ capture(csvfield), ',',
capture(csvfield), ',',
capture(csvfield), ',',
capture(csvfield), ',',
capture('CODE', 1+ digits), ',',
capture(1+ lineChar), cr, lf,
capture(csvfield), ',',
capture(csvfield), ',',
capture(csvfield), ',',
capture(csvfield), ',',
capture('CODE', 1+ digits), ',',
capture(1+ lineChar) ]
and replace with:

Code: Select all

$1,$2,$3,$4,$5,$6
$1,$2,$3,$4,TAG,XX,XX,
$7,$8,$9,$a,$b,$c
Watch that there are no trailing cr/lfs on these strings when you paste them. The 2xTAG fields can be handled very similarly.

If you need help combining the fields please drop me an email.
alexgrainger
Posts: 5
Joined: Wed Dec 15, 2004 10:13 pm

combining lines

Post by alexgrainger »

Thank you for getting back to me - this work just as we needed!

We now have data in the following format:

1,0,09.07.04,18:20:12,CODE39,Len:6,002509
1,0,09.07.04,18:20:13,TAG,4002,0000000102E2803A,
1,0,09.07.04,18:20:16,CODE39,Len:6,002508
1,0,09.07.04,18:20:16,TAG,XX,XX,
1,0,09.07.04,18:20:47,CODE39,Len:6,002508
1,0,09.07.04,18:20:47,TAG,4002,0000000102E28CA5,
1,0,13.07.04,11:29:24,CODE128,Len:7,97814
1,0,13.07.04,11:29:40,TAG,4002,0000000102DF0257,
1,0,13.07.04,11:29:40,CODEXX,XX,XX,
1,0,13.07.04,11:29:40,TAG,4002,0000000102DF0257,
1,0,13.07.04,11:29:42,CODE128,Len:7,97815
1,0,13.07.04,11:29:43,TAG,4002,0000000102E390BC,

What code would we need to get this data into the following format:

1,0,09.07.04,18:20:12,CODE39,Len:6,002509,1,0,09.07.04,18:20:13,TAG,4002,0000000102E2803A,
1,0,09.07.04,18:20:16,CODE39,Len:6,002508,1,0,09.07.04,18:20:16,TAG,XX,XX,
1,0,09.07.04,18:20:47,CODE39,Len:6,002508,1,0,09.07.04,18:20:47,TAG,4002,0000000102E28CA5,
1,0,13.07.04,11:29:24,CODE128,Len:7,97814,1,0,13.07.04,11:29:40,TAG,4002,0000000102DF0257,
1,0,13.07.04,11:29:40,CODEXX,XX,XX,1,0,13.07.04,11:29:40,TAG,4002,0000000102DF0257,
1,0,13.07.04,11:29:42,CODE128,Len:7,97815,1,0,13.07.04,11:29:43,TAG,4002,0000000102E390BC,

Does it matter that some lines end in commas and some don't?

Kind regards,

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

Post by DataMystic Support »

Hi Alex,

This is pretty easy to do using the CSVField token of EasyPatterns. I can leave it to you as an exercise, or we'd be happy to send you a filter to do it when you purchase TextPipe Pro. I hope you can see how good the support is!
alexgrainger
Posts: 5
Joined: Wed Dec 15, 2004 10:13 pm

Post by alexgrainger »

Using the following code, it is nearly working:

[ capture(csvfield), ',',
capture(csvfield), ',',
capture(csvfield), ',',
capture(csvfield), ',',
capture('CODE', 1+ digits), ',',
capture(1+ lineChar),cr, lf,
capture(csvfield), ',',
capture(csvfield), ',',
capture(csvfield), ',',
capture(csvfield), ',',
capture('TAG'), ',',
capture(csvfield), ',',
capture(csvfield)
]

Replace with : $1,$2,$3,$4,$5,$6,$7,$8,$9,$a,$b,$c,$d

INPUT DATA
1,0,04.08.04,15:56:02,CODE128,Len:7,37779
1,0,04.08.04,15:56:11,TAG,4002,0000000102D53A75,
1,0,04.08.04,15:56:31,CODE128,Len:7,38450
1,0,04.08.04,15:56:32,TAG,4002,0000000102DF2A7D,
1,0,04.08.04,15:56:33,CODE128,Len:7,38104
1,0,04.08.04,15:56:35,TAG,4002,0000000102DEFFA0,
1,0,04.08.04,15:57:00,CODE128,Len:7,38103
1,0,04.08.04,15:57:02,TAG,4002,0000000102DF2B93,
1,0,04.08.04,15:57:04,CODE128,Len:7,37777
1,0,04.08.04,15:57:05,TAG,4002,0000000102DF0E9F,
1,0,04.08.04,15:57:07,CODE128,Len:7,38102
1,0,04.08.04,15:57:18,TAG,4002,0000000102E36EFB,
1,0,04.08.04,15:57:19,CODE128,Len:7,37776
1,0,04.08.04,15:57:21,TAG,4002,0000000102D54FE8,
1,0,04.08.04,15:57:34,CODE128,Len:7,38101
1,0,04.08.04,15:57:38,TAG,4002,0000000102D5F15F,
1,0,04.08.04,15:57:39,CODE128,Len:7,37775
1,0,04.08.04,15:57:40,TAG,4002,0000000102E2D5CF,
1,0,04.08.04,15:58:10,CODE128,Len:7,38100
1,0,04.08.04,15:58:11,TAG,4002,0000000102DEFDF6,
1,0,04.08.04,15:58:14,CODE128,Len:7,37773
1,0,04.08.04,15:58:15,TAG,4002,0000000102D54D23,
1,0,04.08.04,15:59:07,TAG,4002,0000000102DF28CE,
1,0,04.08.04,15:59:12,CODE128,Len:7,37772
1,0,04.08.04,15:59:13,TAG,4002,0000000102E2D8DB,
1,0,04.08.04,15:59:56,CODE128,Len:7,37771
1,0,04.08.04,15:59:58,TAG,4002,0000000102DEDCC2,
1,0,04.08.04,16:00:01,CODE128,Len:7,37770
1,0,04.08.04,16:00:02,TAG,4002,0000000102DF27B7,
1,0,04.08.04,16:00:13,CODE128,Len:7,37769
1,0,04.08.04,16:00:34,TAG,4002,0000000102D5400B,
1,0,04.08.04,16:00:36,CODE128,Len:7,37768
1,0,04.08.04,16:00:37,TAG,4002,0000000102E331C7,
1,0,04.08.04,16:00:48,CODE128,Len:7,37767
1,0,04.08.04,16:00:58,TAG,4002,0000000102D53B3E,
1,0,04.08.04,16:00:59,CODE128,Len:7,37766
1,0,04.08.04,16:01:00,TAG,4002,0000000102E39A04,
1,0,04.08.04,16:01:15,CODE128,Len:7,37765
1,0,04.08.04,16:01:30,TAG,4002,0000000102D54C96,

OUTPUT DATA

1,0,04.08.04,15:56:02,CODE128,Len:7,37779,1,0,04.08.04,15:56:11,TAG,4002,0000000102D53A75,
1,0,04.08.04,15:56:31,CODE128,Len:7,38450,1,0,04.08.04,15:56:32,TAG,4002,0000000102DF2A7D,
1,0,04.08.04,15:56:33,CODE128,Len:7,38104,1,0,04.08.04,15:56:35,TAG,4002,0000000102DEFFA0,
1,0,04.08.04,15:57:00,CODE128,Len:7,38103,1,0,04.08.04,15:57:02,TAG,4002,0000000102DF2B93,
1,0,04.08.04,15:57:04,CODE128,Len:7,37777,1,0,04.08.04,15:57:05,TAG,4002,0000000102DF0E9F,
1,0,04.08.04,15:57:07,CODE128,Len:7,38102,1,0,04.08.04,15:57:18,TAG,4002,0000000102E36EFB,
1,0,04.08.04,15:57:19,CODE128,Len:7,37776,1,0,04.08.04,15:57:21,TAG,4002,0000000102D54FE8,
1,0,04.08.04,15:57:34,CODE128,Len:7,38101,1,0,04.08.04,15:57:38,TAG,4002,0000000102D5F15F,
1,0,04.08.04,15:57:39,CODE128,Len:7,37775,1,0,04.08.04,15:57:40,TAG,4002,0000000102E2D5CF,
1,0,04.08.04,15:58:10,CODE128,Len:7,38100,1,0,04.08.04,15:58:11,TAG,4002,0000000102DEFDF6,
1,0,04.08.04,15:58:14,CODE128,Len:7,37773,1,0,04.08.04,15:58:15,TAG,4002,0000000102D54D23,
1,0,04.08.04,15:58:15,CODEXX,XX,XX

1,0,04.08.04,15:59:07,TAG,4002,0000000102DF28CE,
1,0,04.08.04,15:59:12,CODE128,Len:7,37772,1,0,04.08.04,15:59:13,TAG,4002,0000000102E2D8DB,
1,0,04.08.04,15:59:56,CODE128,Len:7,37771,1,0,04.08.04,15:59:58,TAG,4002,0000000102DEDCC2,
1,0,04.08.04,16:00:01,CODE128,Len:7,37770,1,0,04.08.04,16:00:02,TAG,4002,0000000102DF27B7,
1,0,04.08.04,16:00:13,CODE128,Len:7,37769,1,0,04.08.04,16:00:34,TAG,4002,0000000102D5400B,
1,0,04.08.04,16:00:36,CODE128,Len:7,37768,1,0,04.08.04,16:00:37,TAG,4002,0000000102E331C7,
1,0,04.08.04,16:00:48,CODE128,Len:7,37767,1,0,04.08.04,16:00:58,TAG,4002,0000000102D53B3E,
1,0,04.08.04,16:00:59,CODE128,Len:7,37766,1,0,04.08.04,16:01:00,TAG,4002,0000000102E39A04,
1,0,04.08.04,16:01:15,CODE128,Len:7,37765,1,0,04.08.04,16:01:30,TAG,4002,0000000102D54C96,
1,0,04.08.04,16:01:31,CODE128,Len:7,37764,1,0,04.08.04,16:01:33,TAG,4002,0000000102DEF1CC,

Why will it not combine the dummber CODE row with the TAG row?

Kind regards,

Alex
alexgrainger
Posts: 5
Joined: Wed Dec 15, 2004 10:13 pm

Post by alexgrainger »

Hi,

Just seen your message!

I think we will almost certainly be purchasing Textpipe PRO - this package seems to be able to everything we could ever want! As we are in the UK, will we need to pay any tax on the prices you quote on your site? How soon after we purchase the software could we have a product key?

Many thanks,

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

Post by DataMystic Support »

Hi Alex,

Yes, I believe you will have to pay VAT on the amount. You can download the software immediately after your purchase is approved (typically 2 minutes-2 hours, but occasionally more).

Your CODEXX row does not contain digits, so the pattern

capture('CODE', 1+ digits)

will not match it. Try

capture('CODE', 1+ not ',' )

instead.
Post Reply