Page 1 of 1
Textpipe Engine cut option (columns / field)
Posted: Mon May 28, 2012 3:29 am
by rconn
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.
Re: Textpipe Engine cut option (columns / field)
Posted: Mon May 28, 2012 11:43 am
by DataMystic Support
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.
Re: Textpipe Engine cut option (columns / field)
Posted: Mon May 28, 2012 8:56 pm
by rconn
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?
Re: Textpipe Engine cut option (columns / field)
Posted: Mon May 28, 2012 9:16 pm
by rconn
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.
Re: Textpipe Engine cut option (columns / field)
Posted: Tue May 29, 2012 8:58 am
by DataMystic Support
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.