Welcome to Dream.In.Code
Getting Help is Easy!

Join 117,164 Programmers for FREE! Ask your question and get quick answers from experts. There are 2,487 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



How to skip blank lines while reading a file in python?

 
Reply to this topicStart new topic

How to skip blank lines while reading a file in python?

gijig
post 15 May, 2008 - 12:11 AM
Post #1


New D.I.C Head

*
Joined: 14 May, 2008
Posts: 5

Hi all,..please reply
User is offlineProfile CardPM

Go to the top of the page


no2pencil
post 15 May, 2008 - 12:16 AM
Post #2


Wet D.I.C.

Group Icon
Joined: 10 May, 2007
Posts: 5,388



Thanked 35 times

Dream Kudos: 2325

Expert In: Goofing Off

My Contributions


Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

code.gif
User is offlineProfile CardPM

Go to the top of the page

MitkOK
post 15 May, 2008 - 05:31 AM
Post #3


D.I.C Regular

Group Icon
Joined: 9 Aug, 2007
Posts: 289



Thanked 9 times

Dream Kudos: 250
My Contributions


python
infile = open("text.txt","r")

for line in infile:
if not line.strip():
continue
else:
print line
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 10/6/08 11:12AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month