473,387 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How do i read line from an input file, without the /n

How do i read line from an input file, without the /n ?
the readline function returns also the /n character at the end. i need
to read a line without the training /n
is this possible?

thanks, Dorit

Dec 13 '05 #1
4 2807
f.readline().rstrip('\n') should do it. If you are sure that lines
always end in '\n', then you could even use f.readline()[:-1]

Dec 13 '05 #2
"doritrieur" <do********@hotmail.com> wrote:
How do i read line from an input file, without the /n ?
the readline function returns also the /n character at the end. i need
to read a line without the training /n


so strip if off!

line = line[:-1] # remove last char

see also:

http://www.python.org/doc/faq/progra...s-from-strings

</F>

Dec 13 '05 #3
thanks all for your replies! it did helped me!
by the way, i am really new to phyton and to programming, can anyone
refer me to an online source that supplies the relevant data for syntax
ect?

thanks, Dorit.

Dec 14 '05 #4
doritrieur wrote:
can anyone
refer me to an online source that supplies the relevant data for syntax

http://rgruet.free.fr/PQR2.3.html
http://www.google.com

Dec 14 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: sea | last post by:
I have text files in the following format: 123,34, ,345,890, 123,23 .. .. .. As you can see, the problem is that (1) the commas can occur in
17
by: Guyon Morée | last post by:
what is the difference? if I open a text file in binary (rb) mode, it doesn't matter... the read() output is the same.
40
by: Abby | last post by:
My .dat file will contain information like below. /////////// First 0x04 0x05 0x06 Second 0x07
1
by: Magix | last post by:
Hi, I have these string data: str_data1, str_data2, str_data3, which capture some value after a routine process A. Then I would like to write (append) these 3 string values into a text file each...
9
by: Carramba | last post by:
#include <stdio.h> int main( void ){ char cQuit = 'a'; char cKommando , artistNamn , skivansNamn , cChar; int cK ; FILE *pekaFile; printf( "l - for read file\n"); printf( "s - for writte...
9
by: olson_ord | last post by:
Hi, My ascii file is not exactly a comma separated file. The following is a small but complete example of such a file. (This is the ISCAS circuit file format that I need to read in.) ...
1
by: Jose Reckoner | last post by:
I'm running python 2.3 on Windows XP. Anyone have a quick small script to convert .DT1 and .DEM data to ASCII or some other format? I don't need a viewer. Thanks!
2
by: Rajen | last post by:
Suppose the field length is 25 characters. After entering the 25th character, it should be available to process. Program should not wait for the user to press enter/return key. Thank you.
9
by: =?Utf-8?B?QnJpYW4gQ29vaw==?= | last post by:
I want to open a text file and format it into a specific line and then apply color to a specific location of the text and then display it in a RichTextBox after all of this is done. I can do all...
63
by: Bill Cunningham | last post by:
I don't think I can do this without some help or hints. Here is the code I have. #include <stdio.h> #include <stdlib.h> double input(double input) { int count=0,div=0; double...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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,...

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.