Page 1 of 1
change last digit of numeric fields based on rule
Posted: Wed Jun 10, 2009 10:37 pm
by hemashah
Hi,
I have csv file. I need to replace last digit of numeric field with the following sample rule:
Replace last digit with { when last digit is 0 and it is +ve no
Replace last digit with 1 when last digit is 1 nd it is + ve no
Replace last digit with a when last digit is 1 and it is -ve no.
How can we replace last digit of each column? There are 50 columns in the csv file.
Thanks,
Hema.
Re: change last digit of numeric fields based on rule
Posted: Wed Jun 10, 2009 10:44 pm
by DataMystic Support
Use something like this:
Code: Select all
Restrict fields:Comma-delimited field 1 .. field 50
| [X] Process fields individually
| [X] Exclude delimiter
| [X] Exclude quotes (if present)
| Delimiter Type: 0
| Custom delimiter:
| [ ] Has Header
|
|--Perl pattern [.$] with []
| [ ] 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
|
+--Perl pattern [] with []
[ ] 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
Re: change last digit of numeric fields based on rule
Posted: Wed Jun 10, 2009 10:55 pm
by hemashah
What pattern match can I use so that it checks for +ve and -ve numeric fields?
How can I check for last digit only and replace last digit with predefined character.
Thanks,
Hema.
Re: change last digit of numeric fields based on rule
Posted: Thu Jun 11, 2009 11:48 am
by DataMystic Support
For a negative number, use
Then set the replace to send variable 1 to a subfilter which contains your search/replace list.
For a positive number, use
ie 'not a hyphen'