|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
Read txt file line by line
Have a txt file and i want to read line by line...
Only a prob. the dimension is 49 mb !!!! EXistis a best way to read in very fast time? HELP! |
|
#2
|
|||
|
|||
|
I'd be working on a way to not have a 49mb text file. That's way too big for a text file. You could store lines of text in a database table, for one.
But to read a text file you can either use the built-in file functions in vb6, or use the filesystem object.
__________________
====== Doug G ====== "Hide, hide witch! The good folk come to burn thee. Their keen enjoyment hid behind their gothic mask of duty." -Mark Clifton |
|
#3
|
||||
|
||||
|
Code:
Sub ExampleReadLineByLine()
Dim FileID As Integer
Dim strOneLine As String
FileID = FreeFile
Open "e:\somefile.txt" For Input As #FileID
Do Until EOF(FileID)
Line Input #FileID, strOneLine
Debug.Print strOneLine
Loop
Close #FileID
End Sub
It won't care if its 49GB but it will take a long time to parse ;-)
__________________
medialint.com "Energy has the opportunity to change the climate if it's done right." - Sen. John Ensign, R-Nev. (quoted out of context) |
|
#4
|
||||
|
||||
|
49 MB? Haven't you consider making a database out of it. Why do want to read it line by line? Are you searching a keyword on the plain text file?
|
|
#5
|
|||
|
|||
|
Quote:
Yes... line by line because i want store in var a particular string from line of txt file. |
|
#6
|
||||
|
||||
|
Quote:
If you are finding for a line of text you can use Richtextbox control. Just like Micorosoft word it has a .Find properties for finding a word in a paragraph. |
|
#7
|
||||
|
||||
|
I'd try the straight read method before trying to load a 49MB file into a rich text control. I do similar to clean data in large flat files which are often 50-100MB before importing to a db (and writing to a second file to boot). Its not so painfully slow as you might think. I'd reckon on a typical computer it would run several times by the time a 49MB doc loaded into the rtf control :-)
|
|
#8
|
||||
|
||||
|
Seriously - I'd be using SQL Server and DTS to get that sucker into more searchable format. DTS would make short work of 49MB, a simple import wouldn't take very long to create, and it would be a hell of a lot easier to search in SQL.
__________________
Fisherman "Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage -- to move in the opposite direction." - A.Einstein |
|
#9
|
||||
|
||||
|
The problem is if the OP has SQL Server 2k or 2005.
Hey Medialint, I haven't tried working with 49 MB flat file because i think it would be slow and working around with that file will put much load on the memory. Anyway, I just cant stand the idea of having that file in the first place. Creating a database i think is the best approach. |
|
#10
|
|||
|
|||
|
Use Microsoft Scripting Runtime (scrrun.dll) References
Hello everyone,
You may use this code. Please add first: "Microsoft Scripting Runtime (scrrun.dll)" from menu: "Project" -> "References..." Code:
Private Sub GetRecordFromTextFile(strFileName As String)
On Error GoTo ErrHandler
Dim fso As FileSystemObject
Dim TextStream As TextStream
Dim lRows As Long, sLine As String
'Create object by using FSO
Set fso = CreateObject("Scripting.FileSystemObject")
'Open file, put the content to TextStream
Set TextStream = fso.OpenTextFile(strFileName)
'Loop starts here...
Do While TextStream.AtEndOfStream = False
'Read each line... here you can get the string each line
'its up to you, whether you want to process this string
'from sLine variable ... :-)
sLine = TextStream.ReadLine
'Update the counter
lRows = lRows + 1
Loop
'Dont forget to close the TextStream after finish
TextStream.Close
'If you want to get the rows from text file, get it from lRows
Exit Sub
ErrHandler:
MsgBox Err.Number & " - " & _
Err.Description, _
vbCritical, _
"Error GetRecordFromTextFile"
End Sub
Hope this helpful. Cheers! Best regards, Masino Sinaga |
|
#11
|
|||
|
|||
|
javascript google map help
Hi,
I have a javascript code and HTML code. Basically I want to be able to put a number of postcode inside the Google Map. I don't understand programming, however i think this should be a relative job for a pro. If you can help me by editing the code, it will be great. I want to display a postcode marker on the map. To do this, the javascript will have to read it from a txt file, where all the postcode will be seperated by comma, or postcode displayed line by line, which ever ways you find it easier to write. If possible, can you please write a loop for me, so that by just pressing one button, the script will read the code line by line? then generate the marker automatically? I cannot post the code here, as I am a new member, if you can pm me, then i will try email u the code or something.... Thank you. JBCB |
|
#12
|
||||
|
||||
|
Quote:
|