473,513 Members | 2,537 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

using the "readline" function to read a specific line

1 New Member
i am trying to write code to assign values from a line of a text file to variables in my program. the problem is that I don't need all the values written in the text file assigned to variables. So. Basically I want to know if there is a way to use "ReadLine" to access specific lines in a text file.

any type of help would be appreciated
Oct 30 '09 #1
1 1934
tlhintoq
3,525 Recognized Expert Specialist
So you're saying you only need lines 10, 15, and 21 for example?
Read all the lines into an array, then use array elements 9, 14 and 20
Oct 30 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
8689
by: peter leonard | last post by:
Hi, I having a problem with reading each line from a text file. For example, the file is a text file named 'test.txt' with the following content : line 1 line 2 line 3 line 4 line 5
0
1608
by: Edvard Majakari | last post by:
Suppose you have a program containing commands and file name parameters. A simple class providing completion could first read all the commands to list, and extend that list later using all file names in given directory. This way a user could tab-complete (using readline.parse_and_bind('tab: complete')) any command and any file. Eg. if a...
3
14365
by: Laurent | last post by:
Hello, is it possible to read a file in python line by line by redefining a new end-of-line delimiter ? I would like for example to have the string "END" being the new delimiter for each line. Thanks
1
2742
by: Newgene | last post by:
Hi, group, I have python2.3 installed on win2k. I noticed that when I open a dos format text file (eol is '\r\n'), readline() always returns a line ending with '\n' only, not '\r\n'. While I read the same file on unix, it returns a line ending with '\r\n' correctly. This makes me difficult to determine the format of a text file, dos or unix....
2
1886
by: Macisu | last post by:
Hi I am using the object Stream Reader to read Files. The method ReadLine() does not read the character ñ o Ñ. What Can i do? Helpme please thanks
3
5786
by: CD | last post by:
Hi, I am getting a problem using the following piece of code: Dim strfile As Object Set strfile = FSO.OpenTextFile(stFilePath, 1) Do While Not strfile.AtEndOfStream strtext = strfile.ReadLine Loop
5
7023
by: Howard Kaikow | last post by:
How does one determine the number of lines before using ReadLine. This would enable the ReDim to be out of the loop. sReader = New StringReader(xxx.GetObjectText_) If Not (sReader Is Nothing) Then i = -1 Do Until sReader.Peek = -1 i = i + 1 ReDim Preserve yyy(i) ' yyy is typed as String yyy(i) = sReader.ReadLine
3
8876
by: Phoe6 | last post by:
Hi all, I just read the manual and got to know I can use a for loop to iterate through the lines in the file. But so far, I was strugling with the following: import os file = open('File1.txt','r') line = file.readline() while line !=' ':
5
2713
by: kj | last post by:
I'm trying to subclass file, overriding the readline method. The new method definition begins with def readline(self, size=None): line = self.file.readline(size) # etc., etc. ....where the self.file attribute is a regular file object. This works fine if I invoke the new method with an integer argument,
0
7270
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7178
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7397
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7128
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7543
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5704
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3242
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
817
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
473
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.