|
-
Dec 22nd, 2007, 03:18 PM
#1
Hyperactive Member
Re: Sugestion about reading huge text file
 Originally Posted by leinad31
No way to read from the end of the file backwards, only forward even by selecting an arbitrary position in file.
.
i am sorry, but that's just simply wrong.
mshttp will allow you to do so, or any other http provider for that manner, you dont need any server software installed, just a remotely decent server installation.
read up about the range header:
W3C HTTP specification : Range Headers
do a head request, notice the "Content-Length", and subtract, oh, say 1000000 from that to download the last meg.
once the sctring is in vb, Reverse() it if need be, and you should good to go!
-
Dec 22nd, 2007, 05:52 PM
#2
Re: Sugestion about reading huge text file
 Originally Posted by rnd me
once the sctring is in vb, Reverse() it if need be, and you should good to go!
Do you fully understand what you just suggested?
We are talking here about huge amount of characters to be reversed.
That means they will be doubled (at least) before you know it and therfore it may have significant impact on your entire system (performance wise of course).
Besides, what's http got to do with this if file is local or reachable within lan?
Last edited by RhinoBull; Dec 22nd, 2007 at 05:56 PM.
-
Dec 23rd, 2007, 04:35 AM
#3
Hyperactive Member
Re: Sugestion about reading huge text file
 Originally Posted by RhinoBull
Besides, what's http got to do with this if file is local or reachable within lan?
http servers allow you to fetch partial files.
Drives, shares, etc typically don't provide that ability.
also i don't think it needs reversed.
if you grab the last 100kb for instance, you can split that by vbcrlf (or whatever).
something like:
Code:
dim lines() as string
dim out as string
lines= split(request, vbcrlf)
lines(0)="" 'throw away the first line, it might be partial.
out=join(lines)
msgbox out
log files are usually pretty easy to parse, being based upon lines. You cannot do this with an xml doc for instance. You could get the ubound of lines above, and get just the last 100 or so. maybe you want to saveSetting the last log event, and automatically download further behind if needed. i leave that up to you. The hard part is getting it...
when i think about files "located on a remote server", i think server. why download 39 megs of redundant data and, as rhino points out, process locally?
working on just the data you need allows maximum efficiency from both a computational and practical standpoint. i believe that what the OP was asking about.
Last edited by rnd me; Dec 23rd, 2007 at 04:48 AM.
-
Dec 23rd, 2007, 11:23 AM
#4
Re: Sugestion about reading huge text file
 Originally Posted by rnd me
... why download 39 megs of redundant data and, as rhino points out, process locally?..
To run program directly on the server you must install it first - far not every company allows that.
Therefore the only option left is mapping folder and on some workstation and process file "locally".
And again, how is http going to help you here I have not a slightest idea.
-
Dec 23rd, 2007, 11:36 PM
#5
Hyperactive Member
Re: Sugestion about reading huge text file
 Originally Posted by RhinoBull
To run program directly on the server you must install it first - far not every company allows that.
Therefore the only option left is mapping folder and on some workstation and process file "locally".
And again, how is http going to help you here I have not a slightest idea.
My idea can best be expressed as an example:
1. open new standard exe
2. add a reference to Microsoft XML, v3.0
3. add a big textbox to the form, make it multi-line
4. paste the code below and press <F5>
Code:
Private Sub Form_Load()
Dim url2 As String ' the address of the page
Dim resp As String ' a string to hold the resulting response
Dim lines() As String ' an array of the results, partitioned by line
Dim out As String ' the final output
url2 = "http://tde.ornl.gov/Wateruse.csv" 'a free data set
resp = getEnd(url2, "5000") 'get the last 5kb
lines = Split(resp, vbLf)
lines(0) = "" 'throw away the first line, it might be partial...
out = Join(lines, vbCrLf)
Text1 = out
End Sub
Function getEnd(url As String, numberOfBytes As String) As String
Dim IO As New MSXML2.XMLHTTP30
Call IO.open("GET", url, False)
Call IO.setRequestHeader("Content-Type", "text/html")
Call IO.setRequestHeader("Range", "bytes=-" & numberOfBytes)
Call IO.send("")
getEnd = IO.responseText
End Function 'getEnd
you should see the last 30-40 lines of a "log-like file"
This is my offer as a response to the original post:
 Originally Posted by RS_Arm
So, this is my question: can I read the file bottom-up using vb6. If so, how?
If not, what kind of access do you recommend me?
If the server that holds your data is not http-addresable, or not a compliant http implementation, then answer to the original question is No, it is not possible. This is not because of a limit of VB6, but of the underlying infrastructure.
There may also be a vendor-proprietary approach to end of file reading, depending upon the type of network access you have to the "remote location". Might be worth checking into if above doesn't work...
Cheers, and good luck.
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
|