How Can I Read Only One Line Or Specific Line Of A Text File
How can i read only one line or specific line of a text file?
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Read From Specific Line In Text File
How can I read and write to a specific line in a textfile.
Say I want to write a string to say line 5 into info.txt and later I want read line 5 from info.txt
thanks Vidar
How Do I Read A SPECIFIC Line From A Text File ?? GURUS PLEASE HELP =)
A few easy questions for you gurus =)
1. How would I read a specific line from a textfile (for example line number 5)
2. How would i read a specific value in a text file? Lets say the file looks like an ini file:
thing1=value1
thing2=value2
How would i read/write from the specific value?? PLEASE HELP!!!!
Is it possible to search for a string in a file without loading it in a textbox? How would i then extract the value of thing2 for example then???
How Would I Read A Specific Line From A Text File As A String?
I would like to read configuration from a text file like config.txt
each line would look like: variable value (for example: version "0.9")
What code would i need to write if i only wanted to extract one variable and it's value from the config.txt?
How would i find the variable and read it's value ????
---------------------
~:{Decayed}:~
the.decayed@usa.net
http://www.q3seek.com
Line By Line Text File Read And Correct Each Line
Can anyone help me create a small program or have any pointers
on pieces of code that reads a text file from folder "unfixed" then
fix the contents and then store the corrected contents
in another folder "fixed" and then move the file in folder "unfixed" to folder "old"
Details of contents.
There is a space infront of each line that should be removed.
Between the first group of numbers and the second there should be a zero for every space.
Then after the second group of numbers there should be just one space and the rest trimed off.
011531015222360000500355 3350505212004 50122
011531015222360000500363 5336305212004 6255
011531015222360000503465 2404505212004 50022
011531015222360000503463 1345205212004 50025
02153101522236 13 1503256
The @ symbol represents where a space should be.
I would like to read the file and then correct it and then
place the fixed contents in another folder with the original name.
Below is how I would like it to look.
01153101522236000050035500000003350505212004@
01153101522236000050036300000005336305212004@
01153101522236000050346500000002404505212004@
01153101522236000050346300000001345205212004@
021531015222360000000013@
Read, Find A Line And Delete The Line In Text File
Hi, I am writing codes to do the following things: read a line from a text file, if this is a matched line, delete the line and go to the next line.
Can any one give me some direction? Such as access mode, method to use, etc.
Thanks.
.Input ( Read Contentsof Text File - Line By Line )
I'm trying to import Data from a text file, which includes the following,
Vessel Name
000115600
000025600
000000000
000089000
000019000
000000000
6670.43
The above file is updated every five minutes and I wish to retreive this data in
order to perform calc's and then display a completion time for a process on the
User Form.
code:-----------------------------------------------------------------------------
---
Open "YourFile.txt" For Input As #1
While Not EOF(1)
Input #1, YourVariable
List1.Additem YourVariable
Wend
Close #1
--------------------------------------------------------------------------------
Instead of adding to a list as in the above example, I want to process it Line by
Line ( How do I achieve this using .Input ).
Help
How To Read Text File Line By Line?
Dears Friends,
I am coding a program to read emails.
Is there a way to read the email body text line by line ? if not possible, how can I set the bodytext to a text file and use that text file to read line by line?
Here is my psuedocode for reading email line by line:
With .bodytext
Loop from line 1 to EOF
If line x has string "Hello" then
If line x + 1 has "Money" then
forward this to youare@somewhere.com
end if
end if
End loop
End with
Here is my psuedocode for set .bodytext to file.
dim sFirststring as string
dim sSecondstring as string
With .bodytext
save the .bodytext to a file name A.txt
sFileName = " C:A.txt"
Open sFileName For Input As #1
Do Until EOF(1)
Input#1, sFirststring, sSecondstring
If Mid(sFirststring, 1, 1) = "Hello" Then
If Mid(sSecondstring, 1, 1) = "Money" Then
forward this to youare@somewhere.com
End IF
End If
Loop
Thanks,
Bil
Read Text File Line-By-Line
I need to take a text file, read it line by line, and put certain lines into an array...
I need some help on the reading line by line part...
Can anyone steer me in the right direction? I don't need to read it all into an array, just 1 line at a time, and if the line meets certain criteria, put THAT LINE in an array...(I can handle the "if it meets certain criteria" part...)
Thanks!!
Read Line By Line Of Text File And Move Content To Excel Record By Record
Hi,
i am trying to move the selective information in the text file to Excel sheet record by record using VB.Can u help me in this regard.
The contents in text file is like:
"http://www.commerx.com/contact.html","inforequest@commerx.com"
"http://www.commerx.com/contact.html","ClientSupport@commerx.com"
"http://www.commerx.com/services-intranets.html","intranets@commerx.com"
"http://www.davacosourcing.com/company/","bignews@davacosourcing.com"
"http://www.davacosourcing.com/company/","careers@davacosourcing.com"
.
.
.
.
.
.
The above information need to be moved in Excel sheet record by record as:
http://www.commerx.com/contact.html inforequest@commerx.com
http://www.commerx.com/contact.html ClientSupport@commerx.com
http://www.commerx.com/services-intranets.html intranets@commerx.com
http://www.davacosourcing.com/company/ bignews@davacosourcing.com
http://www.davacosourcing.com/company/ careers@davacosourcing.com
.
.
.
.
..
Please do help in this regard as there are more than 1000 information that has to moved in the above pattern.
Thanx
babu
Specific Line In Text File
Hi. I once figured out how to get a specific line from a text file, but i have lost that code and i now need it, so i wondered if anyone had anything like it?
What it does is, say lineNum=3, it goes through a file until it gets to the line number 3 in the .txt file.
Really need help.
Thanks
Text File Specific Line
Can somebody show me the syntaxt on how to read just one line of a text file and how to specify which line to read?
e.g. if I have a .ini file like
[PROGRAM NAME]
ODBC
Total_Fields = 6
what syntax should I use to return just the line Total_Fields = 6?
Thanks in advance
Andrew
Text File Specific Line
Can somebody show me the syntaxt on how to read just one line of a text file and how to specify which line to read?
e.g. if I have a .ini file like
[PROGRAM NAME]
ODBC
Total_Fields = 6
what syntax should I use to return just the line Total_Fields = 6?
Thanks in advance
Andrew
Line Input #1, Line...how Do I Read Ahead One Line (or Back Up One Line)
I am loading a file line by line using the LIne Input but at one point i need to look ahead at the next line to decided what to do on the current line...how do i look ahead one line? or how do i use the line Input function and then back up? Any help would be greatly appreciated.
Shane Thomas
p.s. please email replys in addition to the reply of post too
shathoma@nmsu.edu
Reading A Specific Line In A Text File?
Hi all,
I have done a search on reading text files and have not found exactly what I am looking for. Most people what to read 1 line at a time to a text box or read the last line of a text file.
I am trying to write a programme that will give me the best flexibility to produce different size out put prints (from jpegs) when it is finished, but I need help on reading text files.
When printing I can use the paint picture method with no problems and define my out put. What I am looking to do is create a print products folder in the app path, with different text files representing what I want to print. With a structure something like this set out in a text file called “8x10.txt”
Bitmap: 8x10.bmp
High: 8 (or 11520 twips)
Wide: 10 (or 14400 twips)
Then if I want to add a “5x7.txt” there would be a 5x7 option to print also. I know I could use a filelistbox to list my different options, but how do I open a text file and use what are on the different lines to fill in my variables?
Dim PrntHigh as Integer ‘ height of the print
Dim PrntWide as Integer ‘ width of the print
PrntHigh = line 2 of the text file
PrntWide = line 3 of the text file
Any help is greatly appreciated as always.
Regards Tom
Access Specific Line From Text File
Hi,
I need to read text line by line from a text file. I have the following code:
Open "rollup.txt" For Input Lock Read Write As #1
Do While Not EOF(1)
Line Input #1, record
A() = Split(record, ",")
.......
Loop
The code functions as it should; my problem is that the text file is 3 MB in size, and over time, it's size will increase. It currently takes over an hour for the program to process on a 3.6 MHz machine! I need a way to optimize the code as much as possible.
I know there are portions of the data that I can skip. My question: is there a fast way to jump to a specific line in the text file? Can I do so without parsing through every line and storing it in a buffer?
Thanks in advance for all your help!
Writing To A Specific Line In A Text File.
How can I overwrite line one of a text file, but leave the rest of the text file in place?
Is it possible, or will I have to fake it by loading the whole file after line one into the program, then writing a new file with the new line one, and then the rest of the file after?
Reading Specific Line From A Text File In Vb 6
hi guys
have a look at this code
Code:
Open "C:Score.txt" For Input As #1
Text1.Text = Input$(LOF(1), #1)
lblX.Caption = Text1.Text
lblO.Caption = Text1.Text
the score text file contains the following
Code:
2
3
when i run the program, and load the file, the lblX and the lblO
both display everything in the text file
but i would like the lblX to display the first line in the text file ie: 2
and the lblO to display the second line in the text file ie: 3
so how can i do this?
Jump To A Specific Line In A Text File
Hi,
I have a huge text file that I need to read a specific line. The file has 5671 rows and 7743 columns, so it is too big to put into an array quickly. I know which row that I want to read, but I only know how to read from the first row down, so by the end it takes forever.
Here is the code:
aDEMFile = "C: empdem300ft.txt"
iFileNum = FreeFile
Open aDEMFile For Input As iFileNum
'if the position to go to is ahead of the current
'pointer, then move ahead to that position.
If Yposition > tempPosition Then
For i = tempPosition To Yposition - 1
Line Input #iFileNum, str
tempPosition = tempPosition + 1
Let Position = tempPosition
Next
...
Can you jump to a specific record?
Is there a better way?
Or can I easily load this into an array? (it takes forever to load into the array now)
Thanks, Chris
Delete A Specific Line From A Text File?
Hey, look at my other threads for reference. I just need to delete a certain line for a text file. Anyone, how?
Thanx,
Mikelo2k
P.S I have asked alot of questionz today
Need Way To Look At Specific Line In Text File. Tricky
Anyone know of a good package that will open a text file and display the line number you are looking at????? Be great if it was free (Not to the programmer though)???
I have a text file with 100,000 records. I try and pull it into a SQL server but it errors out and gives me the line number (83,001). However, I do not have a way to look at that line to see what the problem is. I had someone with AS400 access pull the file in and for some reason the AS400 will do it and not error. He looked at line 83,001 and it indeed had a problem with respect to bad quote marks. I want to be able to fix the problem myself rather than having him take this step every week when a new text file arrives. I am looking to correct the text file at the source but would like a fix in the mean time.
If I try and use the LINE INPUT function it can not open file and errors out. I believe because it is to large.
Thanks
How Do I Modify A Specific Line In A Text File?
I have a specific file that needs to have the last line modified. I have tried to figure out how to put the file into an array, then loop through the array to find the value that needs modifying, and then modify it. I have not been able to determine how to do this yet. Any help would be most appreciated.
How To Delete A Specific Line From A Text File
Hi!!! I am quite a new user of VB. And i would like to run a very small vb program, that will read a text file, find a specific word and delete the following 10 lines. I hope i made myself clear.
The code that i use is the following. Please help!!!!
Also can I put this code in the Private sub form_load() because the program is only code, it doesn't have any button or control, i dont need a form.
It is quite urgent
Thanks a lot
-------------------------------------------------------------------------------
Public Function DeleteTextLine(fName As String, LineNumber As Long)
Dim FileNum As Long
Dim lngloop As Long
Dim myString As String
Dim Found As Boolean
FileNum = FreeFile
Open "c:psiexecitmmld.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, myString
If Trim(myString) = "PARK" Then 'where it starts
Found = True
For lngloop = 1 To 13
Call deletelines("c:psiexecitmmld.txt", lngloop)
Next lngloop
End If
Loop
Close #1
End Function
-----------------------------------------------------------------------
Help Getting # Of Lines And Reading A Specific Line # From A Text File???
Is there an efficient way of getting the number of lines from a text file? I want to generate a random number based on the total, and read that specific line. Any ideas?
while not eof(filenumber) '''' this method is too slow...
line input filenumber, mystring ''''my text file is 5Mb, 80,000+ lines
wend
Reading And Writing To A Specific Line In A Text File
how do i read and write to a specific line in a text file? i know how to read the whole thing and write to the whole thing but i just want to read and write to a specific line not the whole thing..
for example i want to store program settings in each line say like
first time load: 1
password: pass
and so on
and say they change there pass... i want it to only change line 2.. and leave the rest the same..
[SORTED]Searching Specific Line In Text File?
I have a text file with about 84 lines of text or so. What i'm trying to do it when someone types 32 in a box then a string is changed to what is on line 32 in the text file.
For example if line 64 is hello, when the user types in line 64 in the textbox then the string MyString will = hello.
I want this to be as easy as possible please. Im currently using
VB Code:
Open App.Path & "worlds.txt" For Input As #1Line Input #1, WLine MsgBox WLineClose #1
But can't seem to edit it to search a specific line.
Thanlks in advance!!
Read A Word In A Line Of Text And Delete That Line
I have some aim logs that I'm going to put in .txt format, and I want to be able to delete the text that the other person has written.
Is there a way for me to specify a screen name and have the program delete that line of text?
Thanks,
Brad
How To Read Rich Text Box Content Line By Line
Hi all. I got a rich text box and i wonder how i can read each line of it one by one. For example i want to read each line of it and display it in massage box.
Furthermore, if i have 10 line of content in textbox how i can refrence each line and display it in massage box?
I be happy if some one show me how this can be done.Thanks
Run Time Error When Read File Line By Line
I'm trying to read a txt file line by line that I can stop reading at any place I want.
Below is the code:
VB Code:
Do While Not EOF(1) Line Input #1, fString Text1.Text = Text1.Text + fString + vbCrLfLoop
The problem is, if the txt file has empty lines at the end of it, it will have run time error : "Input past end of file".
Does anyone know how to solve this problem?
Thanks in advance!
Read Specific Line
Can someone tell me how to read the line that start with "03" in a file?
Thks in advance
Read Specific Line
Hi,
In my current project I need to load ever first and every fifth text line (from a txt file for example) to 2 textboxes
However the current code I use only allows me to but all the 10 lines to 10 texboxes and use it after that.
So as far as I know this code is only usable to load either every line to a seperate textbox, or to get the first line from a text file
My current code is:
Private Sub File1_Click()
Open File1.Path + "" + File1 For Input As #1
Line Input #1, a1
Line Input #1, b1
Line Input #1, c1
Line Input #1, d1
Line Input #1, e1
Text1.Text = a1
Text2.Text = b1
Text3.Text = c1
Text4.Text = d1
Text5.Text = e1
End Sub
Hope you can help
tnx in advance,
Maartuh03
Read A Specific Line
Hi i have a text file and i would like to read a specific lines in that file. any one with ideas on how i can do that?
Thanks
Read Specific Line
Hello,
I'm looking at writing a password generator that uses real words. In order to do this I've downloaded a relatively small dictionary text file, about 80K words (600kb), with a word-per-line.
Now, my problem is what is the best way to pick a word out of this file randomly, preferably with FSO?
Currently I count the number of lines in the file and use a random number generator to pick a number within the lines-of-file range. This is where I run into problems/issues. I can read each line into an array, and access the random element as required, but is this the best/most efficient way for such a large number of lines?
Thanks.
[Help] Read Last Line Of A Text File
Hey Guys,
Im in the process of trying to make an application and have come to a stand still, unable to find out how to read _just_ the last line of a text file.
The problem is that, instead of loading XXX.txt which could contain 2000+ lines, then getting the last line, causing major overhead, I am trying to find a method for getting just the last line.
Thanks in advance,
Regards,
Mark
Read A Text File Line
Is there any way to make a VB program read a certain line from a text file?
If you have a computer or Windows 98 question, ask me.
Read Text Per Line From File
Well, my file is named "config.usof" (its just a text file). I've got one value per line and I'd like to dim a value for each line... any help? Thanks guys... ur savin my project
Read Last Line Of Text File
Hi Guys,
I needed some help regarding file reading in VB 6. I am writing a program that needs to insert a record in a text file. The text file has following format..
Date, Time, Open Price, Close price
Now i need to insert record only if date is greater than last date in file.
So everytime I need to insert record, I have to open file and read sequentially and then I reach last record. This takes time.
IS there a way to read such file in binary or whatever so that i can get last record straight away or very quickly without going thru all records one by one.
If there is can anyone post a small code.
[Records in the (text) file is like -
01/01/2006, 1100, 123.33, 155.55
01/01/2006, 1130, 122.22, 134.33
01/01/2006, 1200, 112.22, 124.33
so on ... ]
Thanks a lot,
Cheers,
GR
How Can I Go To Some Line In Text File For Read It?
If I have some text file that contain many line. And I want to go to some line for read it that line. How can I coding this case in VB?
I know that I can use "For" loop to go to that line but I think VB may be has some better way to go to that line directly
|