A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Word » Page Layout
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

How can I delete all blank lines from a plain text file?



 
 
Thread Tools Display Modes
  #1  
Old October 21st, 2005, 12:44 AM
CX
external usenet poster
 
Posts: n/a
Default How can I delete all blank lines from a plain text file?

I have plain text files that have an unknown number of blank lines that I
need to eliminate. Here's a small sample/section of one of them (the ... just
means that there's more text before and after the section):

....
PAMTRAK FORT WASHI
MTKT# 5544043092119 10/06
^

D10/06/2005
N70020051006
T198.00
....


As you can see there's a blank line between the one that has a single ^ on
it and the one beginning with the letter "D". I need to keep all lines that
have text, including those that have the "^" on them and delete the only
blank ones. I can do this manually, but not for files that have a bazillion
lines in them.

I opened the file in Word 2000, clicked the Show/Hide button and it seems
every single line ends with a paragraph character (whatever that reverse P
thing is called). Anyway, I tried to Find and Replace without luck because I
have no idea how to search for the blank line.

As you can see I'm stumped. Anyhow, I'm willing to use ANY application
including DOS ones to get this to happen so any non-Word suggestions are also
welcome.

Thanks to all who respond in advance!
  #2  
Old October 21st, 2005, 01:01 AM
Daiya Mitchell
external usenet poster
 
Posts: n/a
Default How can I delete all blank lines from a plain text file?

You can Find and Replace a paragraph mark with nothing to delete blank
lines.

First make sure that the blank lines are a paragraph mark--click ¶ on the
standard toolbar and you should see a ¶ (paragraph mark) on the empty lines.

To tell Word to Find a paragraph mark, click on More in the Find dialog,
then use the Special menu (you'll see all sorts of options). You can type
in the code as well.


On 10/20/05 4:44 PM, "CX" wrote:

I have plain text files that have an unknown number of blank lines that I
need to eliminate. Here's a small sample/section of one of them (the ... just
means that there's more text before and after the section):

...

PAMTRAK FORT WASHI
MTKT# 5544043092119 10/06
^

D10/06/2005
N70020051006
T198.00
...



As you can see there's a blank line between the one that has a single ^ on
it and the one beginning with the letter "D". I need to keep all lines that
have text, including those that have the "^" on them and delete the only
blank ones. I can do this manually, but not for files that have a bazillion
lines in them.

I opened the file in Word 2000, clicked the Show/Hide button and it seems
every single line ends with a paragraph character (whatever that reverse P
thing is called). Anyway, I tried to Find and Replace without luck because I
have no idea how to search for the blank line.

As you can see I'm stumped. Anyhow, I'm willing to use ANY application
including DOS ones to get this to happen so any non-Word suggestions are also
welcome.

Thanks to all who respond in advance!


--
Daiya Mitchell, MVP Mac/Word
Word FAQ: http://www.word.mvps.org/
MacWord Tips: http://www.word.mvps.org/MacWordNew/
What's an MVP? A volunteer! Read the FAQ: http://mvp.support.microsoft.com/

  #3  
Old October 21st, 2005, 03:16 AM
Suzanne S. Barnhill
external usenet poster
 
Posts: n/a
Default How can I delete all blank lines from a plain text file?

Replacing ^p with nothing will combine all the text into one huge paragraph.
What you want to do is replace ^p^p (two successive paragraph marks) with
^p. This will fail if there is any space on the blank line, so be sure to
display nonprinting characters (Ctrl+*) and look for spaces (dots). You can
remove those first by searching for space^p (where "space" indicates a
press of the Spacebar in the "Find what" box) and replacing with ^p.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

"Daiya Mitchell" wrote in message
.. .
You can Find and Replace a paragraph mark with nothing to delete blank
lines.

First make sure that the blank lines are a paragraph mark--click ¶ on the
standard toolbar and you should see a ¶ (paragraph mark) on the empty

lines.

To tell Word to Find a paragraph mark, click on More in the Find dialog,
then use the Special menu (you'll see all sorts of options). You can type
in the code as well.


On 10/20/05 4:44 PM, "CX" wrote:

I have plain text files that have an unknown number of blank lines that

I
need to eliminate. Here's a small sample/section of one of them (the ...

just
means that there's more text before and after the section):

...

PAMTRAK FORT WASHI
MTKT# 5544043092119 10/06
^

D10/06/2005
N70020051006
T198.00
...



As you can see there's a blank line between the one that has a single ^

on
it and the one beginning with the letter "D". I need to keep all lines

that
have text, including those that have the "^" on them and delete the only
blank ones. I can do this manually, but not for files that have a

bazillion
lines in them.

I opened the file in Word 2000, clicked the Show/Hide button and it

seems
every single line ends with a paragraph character (whatever that reverse

P
thing is called). Anyway, I tried to Find and Replace without luck

because I
have no idea how to search for the blank line.

As you can see I'm stumped. Anyhow, I'm willing to use ANY application
including DOS ones to get this to happen so any non-Word suggestions are

also
welcome.

Thanks to all who respond in advance!


--
Daiya Mitchell, MVP Mac/Word
Word FAQ: http://www.word.mvps.org/
MacWord Tips: http://www.word.mvps.org/MacWordNew/
What's an MVP? A volunteer! Read the FAQ:

http://mvp.support.microsoft.com/


  #4  
Old October 21st, 2005, 04:00 AM
CX
external usenet poster
 
Posts: n/a
Default How can I delete all blank lines from a plain text file?

Thanks for the quick response!
But after reading my description of the problem, I don't think I was clear
enough. What I meant to say was that every line, blank or otherwise,
currently ends with a paragraph mark. I don't wan't to delete the paragraph
marks on the lines that do have text. I only want to delete the lines that
have no text, including their paragraph marks.

* I went ahead and added the paragraph marks as they appear in Word into the
original example below.

So basically, I want to have the sample to end up like this after removing
jus the blank line:

....
PAMTRAK FORT WASHI¶
MTKT# 5544043092119 10/06¶
^¶
D10/06/2005¶
N70020051006¶
T198.00¶
....

Hope this makes more sense and thanks again.


"Daiya Mitchell" wrote:

You can Find and Replace a paragraph mark with nothing to delete blank
lines.

First make sure that the blank lines are a paragraph mark--click ¶ on the
standard toolbar and you should see a ¶ (paragraph mark) on the empty lines.

To tell Word to Find a paragraph mark, click on More in the Find dialog,
then use the Special menu (you'll see all sorts of options). You can type
in the code as well.


On 10/20/05 4:44 PM, "CX" wrote:

I have plain text files that have an unknown number of blank lines that I
need to eliminate. Here's a small sample/section of one of them (the ... just
means that there's more text before and after the section):

...

PAMTRAK FORT WASHI¶
MTKT# 5544043092119 10/06¶
^¶
¶
D10/06/2005¶
N70020051006¶
T198.00¶
...



As you can see there's a blank line between the one that has a single ^ on
it and the one beginning with the letter "D". I need to keep all lines that
have text, including those that have the "^" on them and delete the only
blank ones. I can do this manually, but not for files that have a bazillion
lines in them.

I opened the file in Word 2000, clicked the Show/Hide button and it seems
every single line ends with a paragraph character (whatever that reverse P
thing is called). Anyway, I tried to Find and Replace without luck because I
have no idea how to search for the blank line.

As you can see I'm stumped. Anyhow, I'm willing to use ANY application
including DOS ones to get this to happen so any non-Word suggestions are also
welcome.

Thanks to all who respond in advance!


--
Daiya Mitchell, MVP Mac/Word
Word FAQ: http://www.word.mvps.org/
MacWord Tips: http://www.word.mvps.org/MacWordNew/
What's an MVP? A volunteer! Read the FAQ: http://mvp.support.microsoft.com/


  #5  
Old October 21st, 2005, 04:09 AM
CX
external usenet poster
 
Posts: n/a
Default How can I delete all blank lines from a plain text file?

ah, your reply came in after my re-explanation post, but you nailed it! I
just tried it and it worked perfectly. thank you, thank you, thank you!

And yes, all blank lines in these files never have spaces.

btw, how can I automate this process? I would love to just open a file have
a macro or some other means to make this as easy as possible. And while I'm
at it, how can I distribute the macro to others that may need it? (don't ask
why)

"Suzanne S. Barnhill" wrote:

Replacing ^p with nothing will combine all the text into one huge paragraph.
What you want to do is replace ^p^p (two successive paragraph marks) with
^p. This will fail if there is any space on the blank line, so be sure to
display nonprinting characters (Ctrl+*) and look for spaces (dots). You can
remove those first by searching for space^p (where "space" indicates a
press of the Spacebar in the "Find what" box) and replacing with ^p.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

"Daiya Mitchell" wrote in message
.. .
You can Find and Replace a paragraph mark with nothing to delete blank
lines.

First make sure that the blank lines are a paragraph mark--click ¶ on the
standard toolbar and you should see a ¶ (paragraph mark) on the empty

lines.

To tell Word to Find a paragraph mark, click on More in the Find dialog,
then use the Special menu (you'll see all sorts of options). You can type
in the code as well.


On 10/20/05 4:44 PM, "CX" wrote:

I have plain text files that have an unknown number of blank lines that

I
need to eliminate. Here's a small sample/section of one of them (the ...

just
means that there's more text before and after the section):

...

PAMTRAK FORT WASHI
MTKT# 5544043092119 10/06
^

D10/06/2005
N70020051006
T198.00
...



As you can see there's a blank line between the one that has a single ^

on
it and the one beginning with the letter "D". I need to keep all lines

that
have text, including those that have the "^" on them and delete the only
blank ones. I can do this manually, but not for files that have a

bazillion
lines in them.

I opened the file in Word 2000, clicked the Show/Hide button and it

seems
every single line ends with a paragraph character (whatever that reverse

P
thing is called). Anyway, I tried to Find and Replace without luck

because I
have no idea how to search for the blank line.

As you can see I'm stumped. Anyhow, I'm willing to use ANY application
including DOS ones to get this to happen so any non-Word suggestions are

also
welcome.

Thanks to all who respond in advance!


--
Daiya Mitchell, MVP Mac/Word
Word FAQ: http://www.word.mvps.org/
MacWord Tips: http://www.word.mvps.org/MacWordNew/
What's an MVP? A volunteer! Read the FAQ:

http://mvp.support.microsoft.com/



  #6  
Old October 21st, 2005, 05:05 AM
Suzanne S. Barnhill
external usenet poster
 
Posts: n/a
Default How can I delete all blank lines from a plain text file?

See http://word.mvps.org/FAQs/Formatting/CleanWebText.htm
http://gregmaxey.mvps.org/Clean_Up_Text.htm

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

"CX" cx(remove wrote in message
...
ah, your reply came in after my re-explanation post, but you nailed it! I
just tried it and it worked perfectly. thank you, thank you, thank you!

And yes, all blank lines in these files never have spaces.

btw, how can I automate this process? I would love to just open a file

have
a macro or some other means to make this as easy as possible. And while

I'm
at it, how can I distribute the macro to others that may need it? (don't

ask
why)

"Suzanne S. Barnhill" wrote:

Replacing ^p with nothing will combine all the text into one huge

paragraph.
What you want to do is replace ^p^p (two successive paragraph marks)

with
^p. This will fail if there is any space on the blank line, so be sure

to
display nonprinting characters (Ctrl+*) and look for spaces (dots). You

can
remove those first by searching for space^p (where "space" indicates

a
press of the Spacebar in the "Find what" box) and replacing with ^p.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the

newsgroup so
all may benefit.

"Daiya Mitchell" wrote in message
.. .
You can Find and Replace a paragraph mark with nothing to delete blank
lines.

First make sure that the blank lines are a paragraph mark--click ¶ on

the
standard toolbar and you should see a ¶ (paragraph mark) on the empty

lines.

To tell Word to Find a paragraph mark, click on More in the Find

dialog,
then use the Special menu (you'll see all sorts of options). You can

type
in the code as well.


On 10/20/05 4:44 PM, "CX" wrote:

I have plain text files that have an unknown number of blank lines

that
I
need to eliminate. Here's a small sample/section of one of them (the

....
just
means that there's more text before and after the section):

...

PAMTRAK FORT WASHI
MTKT# 5544043092119 10/06
^

D10/06/2005
N70020051006
T198.00
...



As you can see there's a blank line between the one that has a

single ^
on
it and the one beginning with the letter "D". I need to keep all

lines
that
have text, including those that have the "^" on them and delete the

only
blank ones. I can do this manually, but not for files that have a

bazillion
lines in them.

I opened the file in Word 2000, clicked the Show/Hide button and it

seems
every single line ends with a paragraph character (whatever that

reverse
P
thing is called). Anyway, I tried to Find and Replace without luck

because I
have no idea how to search for the blank line.

As you can see I'm stumped. Anyhow, I'm willing to use ANY

application
including DOS ones to get this to happen so any non-Word suggestions

are
also
welcome.

Thanks to all who respond in advance!

--
Daiya Mitchell, MVP Mac/Word
Word FAQ: http://www.word.mvps.org/
MacWord Tips: http://www.word.mvps.org/MacWordNew/
What's an MVP? A volunteer! Read the FAQ:

http://mvp.support.microsoft.com/




  #7  
Old October 21st, 2005, 05:06 AM
Graham Mayor
external usenet poster
 
Posts: n/a
Default How can I delete all blank lines from a plain text file?

Try the stripmail utility from the downloads page of my web site and see
http://word.mvps.org/FAQs/General/CleanWebText.htm

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org


CX wrote:
Thanks for the quick response!
But after reading my description of the problem, I don't think I was
clear enough. What I meant to say was that every line, blank or
otherwise, currently ends with a paragraph mark. I don't wan't to
delete the paragraph marks on the lines that do have text. I only
want to delete the lines that have no text, including their paragraph
marks.

* I went ahead and added the paragraph marks as they appear in Word
into the original example below.

So basically, I want to have the sample to end up like this after
removing jus the blank line:

...
PAMTRAK FORT WASHI¶
MTKT# 5544043092119 10/06¶

D10/06/2005¶
N70020051006¶
T198.00¶
...

Hope this makes more sense and thanks again.


"Daiya Mitchell" wrote:

You can Find and Replace a paragraph mark with nothing to delete
blank lines.

First make sure that the blank lines are a paragraph mark--click ¶
on the standard toolbar and you should see a ¶ (paragraph mark) on
the empty lines.

To tell Word to Find a paragraph mark, click on More in the Find
dialog, then use the Special menu (you'll see all sorts of options).
You can type in the code as well.


On 10/20/05 4:44 PM, "CX" wrote:

I have plain text files that have an unknown number of blank lines
that I need to eliminate. Here's a small sample/section of one of
them (the ... just means that there's more text before and after
the section):

...

PAMTRAK FORT WASHI¶
MTKT# 5544043092119 10/06¶


D10/06/2005¶
N70020051006¶
T198.00¶
...



As you can see there's a blank line between the one that has a
single ^ on it and the one beginning with the letter "D". I need to
keep all lines that have text, including those that have the "^" on
them and delete the only blank ones. I can do this manually, but
not for files that have a bazillion lines in them.

I opened the file in Word 2000, clicked the Show/Hide button and it
seems every single line ends with a paragraph character (whatever
that reverse P thing is called). Anyway, I tried to Find and
Replace without luck because I have no idea how to search for the
blank line.

As you can see I'm stumped. Anyhow, I'm willing to use ANY
application including DOS ones to get this to happen so any
non-Word suggestions are also welcome.

Thanks to all who respond in advance!


--
Daiya Mitchell, MVP Mac/Word
Word FAQ: http://www.word.mvps.org/
MacWord Tips: http://www.word.mvps.org/MacWordNew/
What's an MVP? A volunteer! Read the FAQ:
http://mvp.support.microsoft.com/



  #8  
Old October 21st, 2005, 10:50 AM
Daiya Mitchell
external usenet poster
 
Posts: n/a
Default How can I delete all blank lines from a plain text file?

Ouch. Thanks for catching that.


On 10/20/05 7:16 PM, "Suzanne S. Barnhill" wrote:

Replacing ^p with nothing will combine all the text into one huge paragraph.
What you want to do is replace ^p^p (two successive paragraph marks) with
^p. This will fail if there is any space on the blank line, so be sure to
display nonprinting characters (Ctrl+*) and look for spaces (dots). You can
remove those first by searching for space^p (where "space" indicates a
press of the Spacebar in the "Find what" box) and replacing with ^p.


--
Daiya Mitchell, MVP Mac/Word
Word FAQ: http://www.word.mvps.org/
MacWord Tips: http://www.word.mvps.org/MacWordNew/
What's an MVP? A volunteer! Read the FAQ: http://mvp.support.microsoft.com/

 




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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Linking text boxes Volunteer Mom Publisher 7 November 12th, 2008 01:29 AM
Ideas On Producing Envelopes & Labels For Data RNUSZ@OKDPS Setting Up & Running Reports 0 April 28th, 2005 03:22 PM
Importing Contacts from Work to Home Computer in Outlook Debbie Contacts 3 March 16th, 2005 09:14 PM
Office 2003 uninstall/reinstall problems Jerryn3 Setup, Installing & Configuration 2 August 2nd, 2004 03:39 PM
Product Key for Office XP P.G.Indiana Setup, Installing & Configuration 1 June 7th, 2004 03:22 AM


All times are GMT +1. The time now is 03:01 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.