I have a CSV file with 3 columns
Field1,Field2,Field3
Example
123,SLSSYS1000,1
123,SLSSYS1000,1
123,SLSSYS1008,1
323,SLSSYS1000,1
323,SLSSYS1008,1
323,SLSSYS1000,1
321,SLSSYS1008,1
321,SLSSYS1000,1
321,SLSSYS1000,1
I would like to change the 1 to 0 if Field2 does not match SLSSYS1008
So my output would look like this
123,SLSSYS1000,0
123,SLSSYS1000,0
123,SLSSYS1008,1
323,SLSSYS1000,0
323,SLSSYS1008,1
323,SLSSYS1000,0
321,SLSSYS1008,1
321,SLSSYS1000,0
321,SLSSYS1000,0
Note: I have both Wildedit and Textpad
Is this possible in either tool?
Thanks
Steve
Change field3 based on Field2 (If not this than 0)
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
-
- Posts: 2461
- Joined: Sun Mar 02, 2003 9:22 pm
In TextPad:
Use Posix regular expression syntax:
Change field 3 to 0 in all records:
One step:
Change field 3 to 0 in records where field 2 is not SLSSYS1008:
Use Posix regular expression syntax:
Two steps:Configure | Preferences | Editor
[X] Use POSIX regular expression syntax
Change field 3 to 0 in all records:
Then change field 3 to 1 in records where field 2 is SLSSYS1008:Find what: (^[^,]+,[^,]+),[^,]+$
Replace with: \1,0
[X] Regular expression
Replace All
In WildEdit:Find what: (^[^,]+,SLSSYS1008),[^,]+$
Replace with: \1,1
[X] Regular expression
Replace All
One step:
Change field 3 to 0 in records where field 2 is not SLSSYS1008:
Search for: (^[^,]+,(?!SLSSYS1008)[^,]+,)[^,]+$
[X] Regular expression
Replace with: $1,0
[ ] Literal replacement [i.e., not selected]