-
Oct 24th, 2013, 02:03 PM
#1
Thread Starter
PowerPoster
READ backward A VERY BIG FILE TXT (approx 6.000.xxx of lines)
READ backward A very, very BIG FILE TXT (approx 6.000.xxx of lines) , how to?
-
Oct 24th, 2013, 07:18 PM
#2
Re: READ backward A VERY BIG FILE TXT (approx 6.000.xxx of lines)
What do you mean "backwards" reading from right to left instead of left to right or reading the file from bottom to top?
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Oct 24th, 2013, 08:05 PM
#3
Re: READ backward A VERY BIG FILE TXT (approx 6.000.xxx of lines)
I suspect it's bottom up... and it's being written to by something else, and all the OP is interested in is the new info that's at the bottom... all without having to first read the first 5,999,999 rows.
-tg
-
Oct 24th, 2013, 09:21 PM
#4
Hyperactive Member
Re: READ backward A VERY BIG FILE TXT (approx 6.000.xxx of lines)
where does the VERY BIG FILE TXT come from ?
cant it be written the correct way around at start ?
: )
-
Oct 25th, 2013, 01:05 AM
#5
Re: READ backward A VERY BIG FILE TXT (approx 6.000.xxx of lines)
Maybe that's not the point
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
-
Oct 25th, 2013, 01:09 AM
#6
Thread Starter
PowerPoster
Re: READ backward A VERY BIG FILE TXT (approx 6.000.xxx of lines)
Originally Posted by Nightwalker83
What do you mean "backwards" reading from right to left instead of left to right or reading the file from bottom to top?
sorry...
... from bottom to top?
adding new notice, the file is arround 156 mb.
-
Oct 25th, 2013, 01:17 AM
#7
Thread Starter
PowerPoster
Re: READ backward A VERY BIG FILE TXT (approx 6.000.xxx of lines)
Originally Posted by techgnome
I suspect it's bottom up... and it's being written to by something else, and all the OP is interested in is the new info that's at the bottom... all without having to first read the first 5,999,999 rows.
-tg
hi Tg....
I have tested a various code to store the file in array and then loop it from bottom to the top and read line with a for next -1, or tested a lbound to unbound ...
But all codee tested go in error because use a big memory.
-
Oct 25th, 2013, 03:31 AM
#8
Re: READ backward A VERY BIG FILE TXT (approx 6.000.xxx of lines)
read the file for binary in chunks (whatever size suits) from end, split the chunks into lines, add the end line of next chunk to first line of last chunk, calculate remaining bytes to read first lines in file
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
-
Oct 25th, 2013, 04:15 AM
#9
Re: READ backward A VERY BIG FILE TXT (approx 6.000.xxx of lines)
Another important information (at least in my opinion): Are those Lines in this TXT-File structured as in "Do all lines have the same length"?
Last edited by Zvoni; Tomorrow at 31:69 PM.
----------------------------------------------------------------------------------------
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------------------
People call me crazy because i'm jumping out of perfectly fine airplanes.
---------------------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad
-
Oct 25th, 2013, 04:22 AM
#10
Re: READ backward A VERY BIG FILE TXT (approx 6.000.xxx of lines)
Here's a simple implementation of Westconn1's suggestion.
Code:
Option Explicit
Private Sub Command1_Click()
Dim intFile As Integer
Dim intFirst As Integer
Dim intI As Integer
Dim intK As Integer
Dim binLast As Boolean
Dim lngPos As Long
Dim lngLen As Long
Dim lngBlk As Long
Dim strBuffer As String
Dim strLines() As String
Dim strFile As String
Dim strTemp As String
lngBlk = 2000
strFile = "c:\MyDir\reverse.txt"
intFile = FreeFile()
Open strFile For Binary As intFile
lngLen = LOF(intFile)
If lngLen < lngBlk Then lngBlk = lngLen
lngPos = lngLen - lngBlk + 1
Do
strBuffer = Space(lngBlk)
Get #intFile, lngPos, strBuffer
intFirst = InStr(strBuffer, vbNewLine)
intFirst = intFirst + 2
strTemp = Mid$(strBuffer, intFirst)
strLines = Split(strTemp, vbNewLine)
For intI = UBound(strLines) To 0 Step -1
Debug.Print strLines(intI)
Next intI
lngPos = lngPos - lngBlk + intFirst - 3
Loop Until lngPos < 0
lngBlk = lngBlk + lngPos
lngPos = 1
strBuffer = Space(lngBlk)
Get #intFile, lngPos, strBuffer
strLines = Split(Mid$(strBuffer, 1, Len(strBuffer) - 1), vbCrLf)
For intI = UBound(strLines) To 0 Step -1
Debug.Print strLines(intI)
Next intI
Close intFile
End Sub
It reads an entire file 'backwards' - you may want to stop it after a certain number of records.
-
Oct 25th, 2013, 04:41 AM
#11
Thread Starter
PowerPoster
Re: READ backward A VERY BIG FILE TXT (approx 6.000.xxx of lines)
Originally Posted by westconn1
read the file for binary in chunks (whatever size suits) from end, split the chunks into lines, add the end line of next chunk to first line of last chunk, calculate remaining bytes to read first lines in file
in chunks (whatever size suits)?????
Code example please?
-
Oct 25th, 2013, 04:43 AM
#12
Re: READ backward A VERY BIG FILE TXT (approx 6.000.xxx of lines)
Originally Posted by luca90
Code example please?
See Post #10
-
Oct 25th, 2013, 05:06 AM
#13
Re: READ backward A VERY BIG FILE TXT (approx 6.000.xxx of lines)
funny that was the value i used too
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
-
Oct 25th, 2013, 05:18 AM
#14
Re: READ backward A VERY BIG FILE TXT (approx 6.000.xxx of lines)
Originally Posted by westconn1
funny that was the value i used too
Great Minds think alike etc.
-
Oct 25th, 2013, 09:05 AM
#15
Hyperactive Member
Re: READ backward A VERY BIG FILE TXT (approx 6.000.xxx of lines)
Code:
Shell "sort /R c:/order.txt /o c:/sorted.txt"
would that help ?
Last edited by Rattled_Cage; Oct 25th, 2013 at 09:06 AM.
Reason: tags
-
Oct 25th, 2013, 01:24 PM
#16
Re: READ backward A VERY BIG FILE TXT (approx 6.000.xxx of lines)
What is the reason for wanting to read it bottom up and do you actually need to read the whole file or just the last part of it?
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
|