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 |
nbehrnd
Messages: 224 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
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
-
Attachment: filter_by_string.dwam
(Size: 0.76KB, Downloaded 46 times)
-
Attachment: raw_data.dwar
(Size: 1.40KB, Downloaded 41 times)
-
Attachment: true.dwar
(Size: 2.26KB, Downloaded 49 times)
-
Attachment: false.dwar
(Size: 2.38KB, Downloaded 38 times)
-
Attachment: demo.gif
(Size: 717.47KB, Downloaded 117 times)
|
|
|