Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Mar 7th, 2006, 8:58 AM   #1
guess
Programmer
 
Join Date: Feb 2006
Posts: 40
Rep Power: 0 guess is on a distinguished road
New line problem

How can I avoid a full blank line while reading information from a text file.
Im going to parse this text and insert the information into a database however there are some blank lines and these get me in trouble because Im parsing the text using explode and Im parsing it according to the \r\n at first.So it gets the blank lines as well.But It mustnt get.
anyone helps??
guess is offline   Reply With Quote
Old Mar 7th, 2006, 11:53 AM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Just preprocess the text to change all instances of \r\n\r\n to \r\n.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Mar 7th, 2006, 2:12 PM   #3
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Why not just check the line length as you go along?
[php]if (strlen($line) > 0)
{
// do stuff
}
else
{
// ignore
}[/php]
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Mar 8th, 2006, 2:47 AM   #4
guess
Programmer
 
Join Date: Feb 2006
Posts: 40
Rep Power: 0 guess is on a distinguished road
Thanx.I have found a different solution.I made the check before inserting into the database...Its something like u said Ooble.
guess is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 1:00 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC