The logfile has about 100,000 lines, so I cannot import it into Excel anymore which I was able to do until recently. Now I heard it was possible to alter an external file - but I don't know how...
Is there a way, that a MAKRO will check into which range of IP-addresses the IP-address of each entry of the logfile falls, and which will then produce the according CustomerID and put it into the logfile???
Re: VBA: CustomerID for IP-Addresses in external logfile.txt
GREAT THANKS SO MUCH!!!
It works great!!! Especially with the ranges.
One slight thing: so far the output newlist.txt contains only IP-Adress and corresponding CustomerID. But it should also have the rest of the original logfile.
How do I have to alter this code line:
VB Code:
Print #f3, logln & Mid(clist, pos, pos1 - pos)
Do you know whether there are limitation, lets say the logfile might eventually have 200,000 lines or 500,000 lines. Do you think it will still work?
this will put the rest of the line from the log after the customer id
i haven't tested the changes
i don't think it will matte how big you logfile gets, but it might need to be changed if your customer list (file) gets too big, as i keep the whole of that file in memory, you didn't indicate how big it might be.
pete
Re: VBA: CustomerID for IP-Addresses in external logfile.txt
Hi, suddenly I have another problem:
I just put the code on a different computer and now I get this error message:
Run-time error '62': Input past end of file
...after this line:
VB Code:
clist = Input(LOF(f2), #f2)
No idea why! I put the same files into the same location on the harddrive, etc...
Can you help me out with that? Yesterday it ran on my computer...
Maybe it is because on this computer I use the full CustID-file which has around 1000 entries and the memory can only handle 256 items??? ???
THANKS again
Last edited by JVLennox; Jul 10th, 2006 at 12:45 PM.
Re: VBA: CustomerID for IP-Addresses in external logfile.txt
Hi Pete!
I tried it again and again, and even got some more memory....
DIDn't help.
I always get the error "Overflow" - so I thought it would be the memory.
The customer file is not really big, has a couple thousand lines.
(I ATTACHED it.)
The code looks like that:
VB Code:
Private Sub Command1_Click()
Dim i As Integer, pos As Integer, mytest As String, pos1 As Integer
Dim f1 As Integer, f2 As Integer, f3 As Integer
Dim li As Integer, strfi As String, arrfi() As String, pard As Boolean
Dim tlen As Integer, myind As String
Dim clist As String, logln As String, iparr() As String
Re: VBA: CustomerID for IP-Addresses in external logfile.txt
i doubt if memory was the problem, i had previously tested with customer file with 100,000 entries
i am not totally certain on this, but the error you are getting is to do with something in the txt file, probably an end of file marker. try a different text file.
your file worked fine on my machine, but it is a copy that has been downloaded, so it has been changed
i had a text file here that was giving the same error, i opened it in notepad, selected all, copied it to a new empty notepad and saved it, the new file then worked ok, but it may depend how the customers.txt file is created as to whether this will help you.
the alternative is to use the line input method to read all lines into a single variable, which is really no harder.
replace clist = Input(LOF(f2), #f2) with