Removing Blank Lines

S

State Troopers

Hi there.

I have written a function which takes a HTML file, and removes all the tags
from it - leaving me with the text I want. I want to be able to store these
strings in a table eventually.

Say this is the html from the webpage:

<BODY BGCOLOR="#FFF500" TEXT="#000000" style="background-color: #FFF500;
margin: 10px;">

<h3 class="red">LAST FIVE SONGS</h3>

<p style="color: #000000;">
CASSIE – ME & YOU<br>MARY J BLIGE – BE WITHOUT YOU<br>TARAS – I WILL LOVE
AGAIN (MAPL)<br>NICKELBACK – SAVIN ME (MAPL)<br>NATASHA BEDINGFIELD –
UNWRITTEN<br></p>


so far..i turns out like this:










CASSIE - ME AND YOU
MARY J BLIGE - BE WITHOUT YOU
TARAS - I WILL LOVE AGAIN (MAPL)
NICKELBACK - SAVIN ME (MAPL)
NATASHA BEDINGFIELD - UNWRITTEN


As you can see, with everyline of HTML that is removed there is a blank line
inserted(so that the text can be seperated...like above)

I now need to remove ALL blank lines.
Leaving me with...
CASSIE - ME AND YOU
MARY J BLIGE - BE WITHOUT YOU
TARAS - I WILL LOVE AGAIN (MAPL)
NICKELBACK - SAVIN ME (MAPL)
NATASHA BEDINGFIELD - UNWRITTEN

and now blank lines.

If this is too time consuming, I could just throw each line into an array,
and then only store the elements that have text in them.

Thanks.
-State
 
J

John Nurick

Assuming it's a string S and the line breaks are CR+LF pairs, start by
doing

S = Replace(S, vbCrLF & vbCrLF, vbCrLF)

and then if necessary use Left(), Right() and Mid() to remove line
breaks from beginning or end of the string.
 
6

'69 Camaro

Hi.
As you can see, with everyline of HTML that is removed there is a blank line
inserted(so that the text can be seperated...like above)

I now need to remove ALL blank lines.

I have a setup for data clean up that you might find interesting. I have a
template database with a template table named tblCleanUp. This table only
has two fields: ID (AutoNumber) and Data (Text, 255). When I need to do
data cleanup in the current Access database, I link to that table in a copy
of the template database, and then import a template make-table query from
that file. I run my algorithms to clean up the data, and each line of
cleaned up data is stored as a record in the linked tblCleanUp table, blank
lines and all. When the clean up algorithm is finished, I run the template
make-table query to insert all of the records currently in the tblCleanUp
table into a new table in the current database, but only change the name of
the destination table to suit the current database.

SELECT * INTO tblMyTable
FROM tblCleanUp
WHERE (Nz(Data, "") <> "")
ORDER BY ID;

The new table is created and I didn't have to do any coding (other than the
WHERE clause in the template query in the template database) to remove those
blanks.

I also have a custom CommandBar button that I push which "flushes" the
"used" copy of the template database. It deletes this copy of the file, then
places a new copy of the template file in the standard work directory for the
next time I need to do data cleanup.

As long as each record of the cleaned up data will fit into a 255 character
text field, this generic solution works for a myriad of data cleanups,
without my having to do any coding to rid myself of the blanks. And I get no
database bloat, either.

And one of these days I'm going to create another custom CommandBar button
that automatically links the tblCleanUp table, imports the make-table query,
prompts me for the name of the new table, alters the imported make-table
query with this table name, runs a standard-named cleanup algorithm, then
activates the "flush" button for me to replace the copy of the template
database file with a new one -- for those days when I'm feeling particularly
lazy and can't find the energy to push more than one button to clean up the
data.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
http://www.Access.QBuilt.com/html/expert_contributors2.html for contact info.
 
Top