Textpipe Engine cut option (columns / field)

Get help with installation and running here.

Moderators: DataMystic Support, Moderators

rconn
Posts: 32
Joined: Wed Feb 29, 2012 11:56 pm

Textpipe Engine cut option (columns / field)

Postby rconn » Mon May 28, 2012 3:29 am

Hi Simon:

I'm trying to figure out how to use textpipeengine.dll to cut text (i.e., by columns or fields). I'm assuming from the docs that I want the "addSelectionFilter" -- is that true? The docs say it "almost always requires sub filters in order to have any effect". Is that still true for a cut operation?

addSelectionFilter also seems somewhat underdocumented (for example, param1, param2, moveTo, delimiter, and customDelimiter). Do you have an example on how to cut a column range, and a delimited fields range?

Thanks.

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

Re: Textpipe Engine cut option (columns / field)

Postby DataMystic Support » Mon May 28, 2012 11:43 am

Hi Rex,

Yes - that is the right filter -the addSelectionFilter() function adds a type of range . The Restriction types require subfilters, but the move/copy/delete types do not.

I must be looking at a newer manual here, it now has:

param1, param2 - the required integer values for the locate method
moveTo : integer - where to move or copy the columns or fields to. Default 1.
processIndividually - whether or not to apply sub filters to each CSV or Tab field individually, or to the fields as one string value. Default false.
excludeDelimiter - whether or not to include the comma or Tab field delimiter when passing the field to the sub filter. Default true.
excludeQuotes - whether or not to include the CSV quotes that may surround the field when passing the field to the sub filter. Default true.
delimiter - (optional) the index of the standard delimiter to use, or 6 for custom, default 0 for CSV
customDelimiter - (optional) the custom delimiter to use, default blank
hasHeader - (optional) true if the file's first row is a header row, default false.
Regards,

Simon Carter, http://DataMystic.com/forums/index.php
http://PredictBGL.com - Insulin dose calculator for Type 1 diabetes
http://DownloadPipe.com - 250,000 free software downloads
http://DetachPipe.com - send huge email attachments

rconn
Posts: 32
Joined: Wed Feb 29, 2012 11:56 pm

Re: Textpipe Engine cut option (columns / field)

Postby rconn » Mon May 28, 2012 8:56 pm

OK, but I still don't understand how to do a "cut". Say I want to extract columns 20 - 40 and put them in a new file. The "copy" duplicates 20-40, and inserts it at the beginning of the line. The "move" moves 20-40 to column 1, but I still have the unwanted 1-20 following it. Do I have to use a restriction type and a subfilter or can I do it in a single AddSelectionFilter call?

rconn
Posts: 32
Joined: Wed Feb 29, 2012 11:56 pm

Re: Textpipe Engine cut option (columns / field)

Postby rconn » Mon May 28, 2012 9:16 pm

Hi Simon:

I haven't been able to figure this out in the GUI either -- if you can provide an example using the TextPipe GUI, I can export the filter to Javascript and interpret the addSelectionFilter syntax from there.

Thanks.

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

Re: Textpipe Engine cut option (columns / field)

Postby DataMystic Support » Tue May 29, 2012 8:58 am

You need to assemble multiple filters to do this - an addSelection, and a Secondary Output Filter.

Code: Select all

Restrict columns:Column 20 .. column 40
|
+--Merge output to file c:\extracted_columns.txt
   


And in VBScript:

Code: Select all

dim f1,f2,f3,f4,f5,f6

TPWindow.startFilters
TPWindow.clearAllFilters
...

f1 = TPWindow.addSelectionFilter( 2, 0, 20, 40, 1, false, false, false, 0, "", false )
TPWindow.startSubfilters
f2 = TPWindow.addSecondaryOutputFilter( 2, 0, false, false, 1, "", "", true, "c:\extracted_columns.txt", false, false, false )
TPWindow.endSubfilters

TPWindow.endFilters


If you want to remove those extracted columns, then you need to add a Delete All filter after the secondary output, but still inside the restriction.
Regards,

Simon Carter, http://DataMystic.com/forums/index.php
http://PredictBGL.com - Insulin dose calculator for Type 1 diabetes
http://DownloadPipe.com - 250,000 free software downloads
http://DetachPipe.com - send huge email attachments


Return to “TextPipe Tips and Tricks, Questions and Support”

Who is online

Users browsing this forum: Baidu [Spider], Google [Bot] and 9 guests