file parsing

General questions about using TextPad

Moderators: AmigoJack, helios, bbadmin, Bob Hansen, MudGuard

Post Reply
ibgadmin
Posts: 7
Joined: Wed Mar 10, 2010 11:35 pm

file parsing

Post by ibgadmin »

I have a particular problem where I need to extract 3 fields from a log file. Not sure if I can attach that or not, but it has a lot of record-structure like rows of data. Basically I want to extract if possible the "CustomerNo:", "OrderNo:" and "CcNum:" fields. Hard to explain w/o providing a sample, can one attach a file for all to look at? There are no full credit card#'s in the file, as they are masked.
User avatar
Bob Hansen
Posts: 1517
Joined: Sun Mar 02, 2003 8:15 pm
Location: Salem, NH
Contact:

Post by Bob Hansen »

It may be possible to do this with TestPad's Regular Expressions.

Submit a sample of the source data, showing the before and after contents. Use a masking character to hide confidential information, but explain the msaked content as alpha or numeric or both, spaces, etc.
Hope this was helpful.............good luck,
Bob
ibgadmin
Posts: 7
Joined: Wed Mar 10, 2010 11:35 pm

Post by ibgadmin »

Bob, I'm a newbie with textpad so how do I submit a sample file? Is there a way to provide an attachment?
User avatar
Mike Olds
Posts: 227
Joined: Wed Sep 30, 2009 3:27 pm
Contact:

Post by Mike Olds »

Hello,

Open file in TextPad
Select representative lines
copy

come to forum
Reply to this topic
Paste

This is also a very good way to compose e-mail in a way that prevents accidental posting of nasty vents, etc.
Thank you, and
Best Wishes,
Obo
http://buddhadust.net/
check out the What's New? Oblog:
http://buddhadust.net/dhammatalk/dhamma ... ts.new.htm
ibgadmin
Posts: 7
Joined: Wed Mar 10, 2010 11:35 pm

Sample data

Post by ibgadmin »

Thanks for that Mike. Sample data is below. What I want to really do is search a log file. When the string "Transaction0019 Request" is found, ideally I would like to capture that line and the next 24 lines (through OrderNo). What makes it even more difficult is if that can be done, I would ideally like to bring that block of data out in one row -- each filed comma delimited. The data wraps a bit below on the first two lines.....
Sample data-----
.log2010-03-09 00:03:49,433 [11] DEBUG Ecometry.Transaction.Transaction0019 [(null)] - ================== Transaction0019 Request ============
RequestId:
RecordId:
Company: 01
Division: 11
UserId: 3164030900034340
IpAddress:
CustomerEdp: 4118025
CcType: VI
CcNum: 1111111111111111
CcExpYy: 10
CcExpMm: 05
TransactionAmt: 00000.00
BirthDate:
SvBalanceInq:
CcSecCode: 100
SSN:
Email: test@aol.com
PhAmount:
ShipToCustomerEdp: 4118025
BmlCategory:
AuthValue:
ECI:
OrderNo: E0093604
User avatar
talleyrand
Posts: 625
Joined: Mon Jul 21, 2003 6:56 pm
Location: Kansas City, MO, USA
Contact:

Post by talleyrand »

Where's the customer number at in the supplied example?
I choose to fight with a sack of angry cats.
User avatar
Bob Hansen
Posts: 1517
Joined: Sun Mar 02, 2003 8:15 pm
Location: Salem, NH
Contact:

Post by Bob Hansen »

Based on your sample....
1. Search for: ^.log.*\n
Replace with: nothing

2. Search for: ^RequestId
Replace with: ~RequestId

3. Search for: \n
Replace with: ,

4. Search for: ~
Replace with: \n
=============================

Use the following settings:
-----------------------------------------
[X] Regular expression
Replace All
-----------------------------------------
Configure | Preferences | Editor
[X] Use POSIX regular expression syntax
-----------------------------------------

This assumes that the first group of data is followed by identical groups of data lines, with RequestID as the first field name.

All four steps could be created into a macro, and assigned a hot key so this could be done with a single keystroke.
Hope this was helpful.............good luck,
Bob
Post Reply