Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / January 2006

Tip: Looking for answers? Try searching our database.

Cleaning up a file

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Steven Drenker - 28 Jan 2006 09:04 GMT
I've got clean up a large file comprised of returns from antispam DNSBL
servers. The data is comprised of records like those shown below (two full
records shown).

I want to remove all the lines EXCEPT the one starting ";; ANSWER SECTION:"
and the line(s) immediately that one. I want to resume deleting lines with
the next line after ANSWER SECTION starting with ";; res options:"

I was thinking of the following logic:
1. Position the cursor at the start of the file
2. Do the first 9 characters of the line match ";; ANSWER"
3. If no, delete the line
4. If yes, move cursor down until a match is found with ";; res options"
5. Resume deleting lines until the next match of ";; ANSWER"

Although this sounds conceptually simple, I can't come up with the code to
execute it.

Any help would be greatly appreciated!

Steve
- - - - - - - - - - - - - - - - - - - - - -
Two DNS records shown below. Delete everything but the two lines marked
"KEEP"

;; res options: init recurs defnam dnsrch
;; got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 15173
;; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 2
;; QUERY SECTION:
;;     218.0.249.210.bl.deadbeef.org, type = ANY, class = IN

;; ANSWER SECTION:                                     <-- KEEP
218.0.249.210.bl.deadbeef.org.  1D IN A  69.6.215.63   <-- KEEP


;; res options: init recurs defnam dnsrch              <-- RESTART DELETE
;; got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 54857
;; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0
;; QUERY SECTION:
;;     218.0.249.210.blackhole.securitysage.com, type = ANY, class = IN


;; res options: init recurs defnam dnsrch
Helmut Weber - 28 Jan 2006 11:00 GMT
Hi Steven,
hmm...,

if you are talking about 1 line paragraphs,
and if I understand the structure correctly
despite what my newsreader shows me,
then check whether a paragraph starts with ";; ANSWER SECTION:"
or starts with a digit.
If not so, delete it.

You may send me a sample file, if you like.

Signature

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"

Jezebel - 28 Jan 2006 11:10 GMT
It's not quite clear what you're trying to do (please proof-read your
posts!) ... but you can probably use Find and Replace to do the whole thing.
As I understand it, you want to keep any sequence that begins ";; ANSWER" up
to, but not including, the next ";; res options". Make two passes, one to
identify all the text you want to keep, the second to delete everything
else --

1. With 'Use wildcards' checked --
   Find: (;; ANSWER[!;]@);
   Replace: \1        Format = Bold

This assumes that there are no other semi-colons between the answer and the
";; res" bit.

2. With 'Use wildcards' unchecked --
   Find: ^?        Format = Not Bold
   Replace:         (leave blank, no format)

> I've got clean up a large file comprised of returns from antispam DNSBL
> servers. The data is comprised of records like those shown below (two full
[quoted text clipped - 40 lines]
>
> ;; res options: init recurs defnam dnsrch
Steven Drenker - 28 Jan 2006 17:16 GMT
Jezebel...excellent! That works perfectly. I hadn't thought about using
expressions with wildcards. I like the [!;]@ expression to find any number
of characters up to the next ";".

Sorry my description wasn't clear. It should have read " the line(s)
immediately FOLLOWING that one." You figured it out though -- I want to keep
the ANSWER section and delete everything else.

I just need to make sure that there is no ";" in any of the information I
want to keep.

I'll automate your solution to clean up the files.
Steve

----------------------------------------------------

It's not quite clear what you're trying to do (please proof-read your
posts!) ... but you can probably use Find and Replace to do the whole thing.
As I understand it, you want to keep any sequence that begins ";; ANSWER" up
to, but not including, the next ";; res options". Make two passes, one to
identify all the text you want to keep, the second to delete everything
else --

1. With 'Use wildcards' checked --
   Find: (;; ANSWER[!;]@);
   Replace: \1        Format = Bold

This assumes that there are no other semi-colons between the answer and the
";; res" bit.

2. With 'Use wildcards' unchecked --
   Find: ^?        Format = Not Bold
   Replace:         (leave blank, no format)

> I've got clean up a large file comprised of returns from antispam DNSBL
> servers. The data is comprised of records like those shown below (two full
[quoted text clipped - 40 lines]
>
> ;; res options: init recurs defnam dnsrch
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.