Re: Create a macro to split a .dwar file into multiple .dwar files [message #2281 is a reply to message #2280] |
Thu, 15 August 2024 20:16 ![Go to previous message Go to previous message](/forum/theme/myThemeWithHFCSS/images/up.png) ![Go to next message Go to previous message](/forum/theme/myThemeWithHFCSS/images/down.png) |
nbehrnd
Messages: 215 Registered: June 2019
|
Senior Member |
|
|
Hello,
for a one-at-a-time, DW very well can help you. Attached below the macro, raw data set and results, and a brief demo with DW 06.02.03
![/forum/index.php?t=getfile&id=874&private=0](/forum/index.php?t=getfile&id=874&private=0)
The idea is to check for the presence of a particular string in the column identifier. For this, the macro asks every line the same test question by the formula
```
if (identifier == askString("enter the identifier of interest"), "true", "false")
```
if a specific string is present at this intersection. The newly calculated column will contain an entry `true` if this is the case, or else the string `false`. (Of course you could opt-in for `active`, `inactive` to designate the two, too.) The flexibility you want is provided by DataWarrior's function `askString()` to allow to recycle the macro's function, to filter for records with an other string in this field. Watch out the pane to the right hand side: we now have a filter which allows to save the visible records per level `true`, or `false`.
While running the macro editor, a double click on `save visible rows` allows you to toggle off the question to manually define the file name (for this sub set of data). This can be useful if i) raw data and the new files to be written are every time in the same location, and ii) the output should every time the same, e.g. `positive.dwar` and `negative.dwar`.
Best regards,
Norwid
|
|
|