-
Aug 3rd, 2018, 07:52 AM
#1
Thread Starter
New Member
extract specific data from txt file
hi can u help me with this project.
to extrtact specific file like date, time, cardnumber, issuer no, account no etc.
this is a multiple file.
[020t 15:34:05 NOTES STACKED
[020t $20170817153408$CARD_EJECT$XXXXXXXXXXXXXXX8265
[020t $20170817153409$CARD_TAKEN$XXXXXXXXXXXXXXX8265
[020t 15:34:09 CARD TAKEN
[020t 15:34:13 NOTES PRESENTED 1,2,1,0
[020t $20170817153415$CASH_TAKEN$XXXXXXXXXXXXXXX8265
[020t 15:34:15 NOTES TAKEN
**********.
DATE-TIME : 08/17/17-16:50:15
ATM ID/SEQ NO. : 63006131/8846
ISSUER NO. : 639403
CARD NUMBER : 130000191826
ACCOUNT NO. : 001101302000
TRANSACTION : CASH WITHDRAWAL
AMT REQ. : 1,700.00
AMT AUTH. : 1,700.00
TRACE NUMBER : 269459
34011512
[020t 15:34:25 TRANSACTION END
[020t
![17-08-17 15:34:25]ACCUMM COUNTER VALUES :1:2:1:0
REJECTED COUNTERS:1:1:2:0
-
Aug 3rd, 2018, 06:00 PM
#2
Re: extract specific data from txt file
you can try like
Code:
Open "c:\temp\card2.txt" For Input As 1
scard = Input(LOF(1), #1)
Close 1
pos = 1
Do
pos = InStr(pos, scard, "DATE-TIME")
If pos = 0 Then MsgBox ("no more transactions"): Exit Do
pos2 = InStr(pos, scard, "TRANSACTION END")
If pos2 = 0 Then MsgBox ("no transaction end"): Exit Do
stran = Mid(scard, pos, pos2 - pos)
pos = pos2
adetails = Split(stran, vbNewLine)
dt = Mid(adetails(0), 13, 17) ' parse the date detail from array
' all details for one transaction should be in the array adetails
' here you need parse the required items from the array to assign the values to your database
Loop
this would not work for your previous sample of file as no transaction end
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|