Search the web
Sign In
New User? Sign Up
datamystic · DataMystic Newsletter
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Want your group to be featured on the Yahoo! Groups website? Add a group photo to Flickr.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Newsletter - file split on words/patterns, and changing specific oc   Message List  
Reply | Forward Message #74 of 89 |


================================================================
DataMystic Newsletter 3 www.datamystic.com
================================================================

Thursday February 17, 2005

Crystal Software has now been 'reborn' as DataMystic Corporation,
and we hope you like the new name and the changes we're making
to the website. The new name suggests optimism and the 'mystic'
suggests that we can help untangle the mess of data so that you
can get on with analysing it.

If only it were that easy!

We have a new release of TextPipe coming out shortly, with new
filters for capturing text and a variety of other enhancements.
We're gradually changing the grids used in the GUI to a new
Unicode-enabled control, which is part of our migration to
Unicode.

If you have an interesting story, tip or use for TextPipe please
send it our way!

Regards,

Simon Carter
CEO, DataMystic

****************************************************************

THIS ISSUE INCLUDES:

1) Changing Specific Occurrences

2) File Split Based On Word or Pattern

3) WANTED: Professional Information Consultants to resell TextPipe

4) Download the Latest TextPipe Pro

****************************************************************
Please forward this newsletter to anyone you think may be interested.
Thank you. Information on how to SUBSCRIBE / UNSUBSCRIBE is at the
bottom.
****************************************************************

CHANGING SPECIFIC OCCURRENCES

Sometimes you want to perform a replacement only when specific
conditions have been met, or according to a calculation. As an
example, we might want to only replace every second (2nd)
occurrence of some found text.

I can't remember the real-life support question that this answers,
so we'll have to make do with this contrived example. Let's say
you have text like this:

**********************************

and you want to change every second '*' to '-' (yes, I know you
could just replace '**' with '*-').

By adding a subfilter to a Script filter, you can programmatically
control when the subfilter is applied.

Here's how the filter looks:

|--Replace [*] with [$0]
| | [ ] Match case
| | [ ] Whole words only
| | [ ] Case sensitive replace
| | [ ] Prompt on replace
| | [ ] Skip prompt if identical
| | [ ] First only
| | [ ] Extract matches
| |
| +--VBScript script Timeout: 10000 milliseconds
| | 'Count the replacements
| |
| | dim a
| |
| | function processLine(line, EOL)
| | a = a + 1
| | if a mod 2 = 0 then
| | processLine = TextPipe.subFilterEntireText(line & EOL)
| | else
| | processLine = line & EOL
| | end if
| | end function
| |
| | sub startJob()
| | a = 0
| | end sub
| |
| | sub endJob()
| | end sub
| |
| | function startFile()
| | startFile = ""
| | end function
| |
| | function endFile()
| | endFile = ""
| | end function
| |
| +--Replace [*] with [-]
| [ ] Match case
| [ ] Whole words only
| [ ] Case sensitive replace
| [X] Prompt on replace
| [ ] Skip prompt if identical
| [ ] First only
| [ ] Extract matches

The key is the use of the TextPipe.subFilterEntireText()
function, which is part of the internal TextPipe automation
object. This object can also be used to log messages, to find
the current filename, to get and set global variables, to display
messages to the user, and to find the current line number and
file offset. If the text to be subfiltered is large, you can
also pass it through the subfilters progressively.

More user filters:
http://www.datamystic.com/textpipe/user_filters.html

****************************************************************

FILE SPLIT BASED ON WORD OR PATTERN

Sometimes you need to do more than split a file based on a
number of lines, an individual character occurring or a byte
count. To split a file based on the location of a word, phrase
or pattern, you can use a token or marker to indicate where
to split the file. Use the following technique:

1. Add a Search/Replace filter that will search for the word,
phrase or pattern you want to split on.

2. Set the replacement text to
\xff - to split on top of the text (and remove it)
$0\xff - to split after the text is found
\xff$0 - to split before the text is found

3. Add a Split filter, to split on the character \xff,
and set the Split Position as for #2.

That's it! All we're doing is inserting a marker character
of ASCII 255 (Hex FF) to tell the split filter where to split.

In TextPipe it looks like this:

|--Perl pattern [MyPhrase] with [\xff]
| [ ] Match case
| [ ] Whole words only
| [ ] Case sensitive replace
| [ ] Prompt on replace
| [ ] Skip prompt if identical
| [ ] First only
| [ ] Extract matches
| Maximum text buffer size 4096
| [ ] Maximum match (greedy)
| [ ] Allow comments
| [X] '.' matches newline
| [ ] UTF-8 Support
|
|--Split at char 255, filename %f.%e.%3.3d, number 0 count 1

****************************************************************

PROFESSIONAL INFORMATION CONSULTANTS WANTED TO RESELL TEXTPIPE

If you have clients who may benefit from TextPipe, we would love to
hear from you. We have a dedicated and friendly support staff, highly
reputable products and a generous commission structure.

If interested in receiving more information, please see:
http://www.datamystic.com/resellers

****************************************************************

DOWNLOAD THE LATEST TEXTPIPE PRO

http://www.datamystic.com/textpipepro2.exe

****************************************************************
This newsletter is sponsored by DataMystic.

It can be reprinted and redistributed as long as the
author and sponsor are acknowledged.










Thu Feb 17, 2005 3:11 am

crystalsoftw...
Offline Offline
Send Email Send Email

Forward
Message #74 of 89 |
Expand Messages Author Sort by Date

================================================================ DataMystic Newsletter 3 www.datamystic.com ...
crystalsoftwareau
crystalsoftw...
Offline Send Email
Feb 18, 2005
1:15 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help