Select all lines from the start... and delete them all

Get help with installation and running here.

Moderators: DataMystic Support, Moderators, DataMystic Support, Moderators, DataMystic Support, Moderators

Post Reply
kobong
Posts: 5
Joined: Sun Oct 08, 2006 5:52 pm

Select all lines from the start... and delete them all

Post by kobong »

Hello

I have filter:

“Select all lines from the start of the file until a line starting with DeliveredDate:”

My question is: how to delete all matching lines (instead of changing them into upper case - as is default now).

I've used subfilter Remove all, but it doesn't work. So: how to delete all matching (to the line: "DeliveredDate:") lines?

Please, give me filter:

“DELETE all lines from the start of the file until a line starting with DeliveredDate:”

Best regards!
Peter
User avatar
DataMystic Support
Site Admin
Posts: 2227
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Post by DataMystic Support »

Did you add this as a subfilter, or just below the select filter? Please email us your filter, or read the help on creating subfilters.
kobong
Posts: 5
Joined: Sun Oct 08, 2006 5:52 pm

Post by kobong »

Hello!

First, I use normal Your VBScript script:

Code: Select all

Filter List
-----------
|--VBScript script  Timeout: 10000 milliseconds
|  |  'Select all lines from the start of the file until a line starting with DeliveredDate:
|  |  
|  |  dim textFound
|  |  
|  |  'Called for every line in the file
|  |  'EOL contains the end of line characters (Unix, DOS or Mac) that must be
|  |  'appended to each line
|  |  function processLine(line, EOL)
|  |  
|  |    if InStr( line, "DeliveredDate:" ) = 1 then
|  |      textFound = true
|  |    end if
|  |  
|  |    if not( textFound ) then
|  |      processLine = TextPipe.subFilterEntireText(line) & EOL
|  |    else
|  |      processLine = line & EOL
|  |    end if
|  |  
|  |  end function
|  |  
|  |  
|  |  'Called before each file is opened -
|  |  'perform per-file initialisation here
|  |  function startFile()
|  |    textFound = false
|  |    startFile = ""
|  |  end function
|  |  
|  |  
|  |  'Called before each file is closed -
|  |  'flush all pending file output here
|  |  function endFile()
|  |    endFile = ""
|  |  end function
|  |  
|  |  
|  |  'Called at the start of a processing job -
|  |  'perform one-time initialisation here
|  |  sub startJob()
|  |    'do nothing
|  |  end sub
|  |  
|  |  
|  |  'Called at the end of a processing job -
|  |  'destroy any declared objects here
|  |  sub endJob()
|  |    'do nothing
|  |  end sub
|  |  
|  |  
|  |
|  +--Convert to UPPERCASE [THERE IS THE CRUCIAL ELEMENT]
|      
+--Output to file(s)

But, please, tell me, what kind of (sub)filter - (sub)command - should I use (instead of default: Convert to UPPERCASE) in order to DELETE all matching lines, it is: form the start of the file until a line starting with DeliveredDate:

Thank You in advance!
Peter
User avatar
DataMystic Support
Site Admin
Posts: 2227
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Post by DataMystic Support »

That VBScript code will not work.

Use this simple search/replace filter instead:

Code: Select all

Perl pattern [(.*)(^DeliveredDate:)] with [$2]
   [ ] Match case
   [ ] Whole words only
   [ ] Case sensitive replace
   [ ] Prompt on replace
   [ ] Skip prompt if identical
   [ ] First only
   [ ] Extract matches
   Maximum text buffer size 409600
   [ ] Maximum match (greedy)
   [ ] Allow comments
   [X] '.' matches newline
   [ ] UTF-8 Support
 
kobong
Posts: 5
Joined: Sun Oct 08, 2006 5:52 pm

Post by kobong »

Thank You, it works indeed, but by the use of the filter:

“select from start to matching line.fll”

tasks could by done more sophisticated, even: faster.

The one thing what the User need is filter:

“remove from start to matching line.fll”

(and – prospectively: “remove from matching line to the end of file.fll”)

but today (7.6.1) there is no such filter(s).

Anyway: Your regex-tip is working. Thank you once more!

Bye, bye.
User avatar
DataMystic Support
Site Admin
Posts: 2227
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Post by DataMystic Support »

Thanks - we'll include those in the next release
Post Reply