Global Variable search/Replace

Get help with installation and running here.

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

Post Reply
theorem5
Posts: 2
Joined: Thu Mar 02, 2017 9:43 am

Global Variable search/Replace

Post by theorem5 »

Is there a way to use a global variable in search and replace? I am sure there is, but I cannot find a way to do it correctly. I first tried by doing it with a line start, and then that did not work, I went a different way, but still no work. My plan is to pass the global variable on the command line, but I am just setting it from now while I test. I am setting the initial value of the @propcode variable to 2550. I know it is getting set correctly because I can add it to each line.

See the attached script that I am trying to process.

Filter List
-----------
Filter options
| [ ] Log to file
| [ ] Append to logfile
| Log filename: textpipe.log
| Threshold 500
|
|--Input from file(s)
| [ ] Confirm before processing each file
| [ ] Confirm before processing read/only files
| [ ] Delete input files after processing
| Process binary files
|
|--** DISABLED ** Ascending ASCII sort (case insensitive), length 32
|
|--Capture to variable @propcode
| Reset: 1
|
|--Remove duplicate lines
| [X] Ignore case
| Start column 1
| Length 32
| [ ] Include One
| format: %d %s
|
|--Move fields:Comma-delimited field 14 .. field 14 move to 1
| Delimiter Type: 0
| Custom delimiter:
| [ ] Has Header
|
|--** DISABLED ** Remove non-matching lines [[linestart @propcode]]
| [ ] Include line numbers
| [ ] Include filename
| [ ] Match case
| [ ] Count matches
| Pattern type: 4
| [ ] UTF8 Support
| [ ] Ignore empty matches
| Context before: 0
| Context after: 0
|
|--Replace [@propcode] with [XXXXXXX]
| [ ] Match case
| [ ] Whole words only
| [ ] Case sensitive replace
| [ ] Prompt on replace
| [ ] Skip prompt if identical
| [ ] First only
| [ ] Extract matches
|
|--Move fields:Comma-delimited field 1 .. field 1 move to 14
| Delimiter Type: 0
| Custom delimiter:
| [ ] Has Header
|
|--Replace [,\r\n] with [\r\n]
| [ ] Match case
| [ ] Whole words only
| [ ] Case sensitive replace
| [ ] Prompt on replace
| [ ] Skip prompt if identical
| [ ] First only
| [ ] Extract matches
|
+--Output to file(s)
[ ] Only update date on changed files
[ ] Append mode
[ ] Change extension to: .txt
[ ] Open output file
Only output modified files [ ] Remove empty output files



Here is some sample data to go along:

10072,203-3221,1/27/2017,0:00,1:10,NULL,1.17,0,0,NULL,2.92,0,0,2550
10072,203-3221,1/27/2017,12:00,12:00,NULL,0,0,0,NULL,-243.36,0,0,2550
10072,203-3221,1/27/2017,12:00,12:00,NULL,0,0,0,NULL,40.72,0,0,2550
10072,203-3221,1/27/2017,12:00,12:00,NULL,0,0,0,NULL,53.36,0,0,2550
10072,203-3221,1/27/2017,12:00,12:00,NULL,0,0,0,NULL,190,0,0,2550
10072,203-3221,1/27/2017,16:30,0:00,NULL,7.5,0,0,NULL,18.75,0,0,2550
10072,203-3221,1/28/2017,17:20,0:00,6.67,0,0,0,16.67,0,0,0,2550
10072,203-3221,1/28/2017,0:00,1:00,1,0,0,0,2.5,0,0,0,2550
10072,203-4399,1/28/2017,9:10,10:30,NULL,1.33,0,0,NULL,9.67,0,0,2550
10072,203-3221,1/29/2017,11:00,15:10,4.17,0,0,0,10.42,0,0,0,2550
10072,203-3221,1/29/2017,15:25,19:50,4.42,0,0,0,11.04,0,0,0,2550
10459,220-7221,2/1/2017,15:06,20:10,5.07,0,0,0,16.97,0,0,0,2550
10459,220-7221,2/3/2017,9:00,13:10,4.17,0,0,0,13.96,0,0,0,2554
10459,220-7221,2/3/2017,13:17,14:00,0.72,0,0,0,2.4,0,0,0,2554
10459,220-7221,2/8/2017,5:30,14:20,8.83,0,0,0,29.59,0,0,0,2550
10459,220-7221,2/9/2017,5:20,13:40,8.33,0,0,0,27.92,0,0,0,2550
10459,220-7221,2/9/2017,14:30,16:40,2.17,0,0,0,7.26,0,0,0,2554
10459,220-7221,2/9/2017,17:08,20:50,3.7,0,0,0,12.4,0,0,0,2554
User avatar
DataMystic Support
Site Admin
Posts: 2227
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Re: Global Variable search/Replace

Post by DataMystic Support »

Just use the command line option:

@<name>=<value>
Predefines the value of the global variable name to the value value

You can also use environment variables using the @macro syntax,

@ENV_varname@
Where varname is the name of an environment variable, this inserts the value of a environment variable e.g. @ENV_OS inserts the text 'Windows_NT' on an NT system.
theorem5
Posts: 2
Joined: Thu Mar 02, 2017 9:43 am

Re: Global Variable search/Replace

Post by theorem5 »

I don't think I explained myself correctly. I know I can pass the variable via the command line. I am confused as to how to set it in the filter. For example, if I have a filter doing "Extract matching lines", how do I set the value for that filter? If I do "[linestart @proptokeep]" it does not work, as I get this error message:

String for 'Extract lines matching [[linestart @proptokeep]]' is invalid - Line 1:1 proptokeep is not a valid keyword, found proptokeep
User avatar
DataMystic Support
Site Admin
Posts: 2227
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Re: Global Variable search/Replace

Post by DataMystic Support »

TextPipe is not designed to evaluate macros in the search field. However, you can use the command line to add a search/replace filter with custom text. Please see the user manual under 'Advanced'
Post Reply