Page 1 of 1

file parsing

Posted: Wed Mar 10, 2010 11:44 pm
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.

Posted: Wed Mar 10, 2010 11:56 pm
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.

Posted: Thu Mar 11, 2010 12:00 am
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?

Posted: Thu Mar 11, 2010 10:26 am
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.

Sample data

Posted: Thu Mar 11, 2010 3:12 pm
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

Posted: Thu Mar 11, 2010 5:31 pm
by talleyrand
Where's the customer number at in the supplied example?

Posted: Sat Mar 13, 2010 1:59 am
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.