file parsing
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
file parsing
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.
- Bob Hansen
- Posts: 1516
- Joined: Sun Mar 02, 2003 8:15 pm
- Location: Salem, NH
- Contact:
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.
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
Bob
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.
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
Best Wishes,
Obo
http://buddhadust.net/
check out the What's New? Oblog:
http://buddhadust.net/dhammatalk/dhamma ... ts.new.htm
Sample data
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
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
- talleyrand
- Posts: 624
- Joined: Mon Jul 21, 2003 6:56 pm
- Location: Kansas City, MO, USA
- Contact:
- Bob Hansen
- Posts: 1516
- Joined: Sun Mar 02, 2003 8:15 pm
- Location: Salem, NH
- Contact:
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.
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
Bob