Macro questions: preserving columnProperty and setting date filter [message #1217] |
Fri, 05 February 2021 16:36 |
Andrew0
Messages: 19 Registered: August 2015
|
Junior Member |
|
|
Hello Thomas,
I have a macro that has the following basic workflow:
- Open a text file
- Apply a template from an existing .dwar file
- Update some filters
I recently discovered the columnProperty field from http://openmolecules.org/forum/index.php?t=msg&goto=765, and am making use of this to link to source data. It seems that when I apply a template that has defined columnProperty values, they are not carried into the new file. Is this expected behavior, or is there a way I can carry these columnProperty values over?
Secondly, one of the filters I update at the conclusion of the macro is a date filter. Does DataWarrior use a standard date format? In the macro the date appears as a float value, which doesn't correspond to date formats that I'm familiar with.
Thank you for your continued development of this tool - it's a huge benefit to the community!
Andrew
|
|
|
Re: Macro questions: preserving columnProperty and setting date filter [message #1224 is a reply to message #1217] |
Thu, 11 February 2021 11:37 |
thomas
Messages: 715 Registered: June 2014
|
Senior Member |
|
|
Hi Andrew,
column properties are considered to belong to the data and not to the definition of how to display the data.
Therefore, they are not part of the template. However, you may use the macro task 'Set Column Properties'
to add (or replace) column properties to a column.
When DataWarrior analyses a column, then it is rather flexible concerning data formats. It basically checks, whether it can find three different values per cell and whether they fit in the range of what could be interpreted as data value. If cell entries are plausible dates, then these are converted into float values representing the number of milliseconds since Jan 1st, 1970. This value is used internally for filtering, axis assignment, etc. And it end up in the template filter section.
(https://currentmillis.com/)
Thomas
[Updated on: Thu, 11 February 2021 11:37] Report message to a moderator
|
|
|
Re: Macro questions: preserving columnProperty and setting date filter [message #1225 is a reply to message #1217] |
Thu, 11 February 2021 19:39 |
Andrew0
Messages: 19 Registered: August 2015
|
Junior Member |
|
|
Thomas,
Thanks very much for your reply. I have two (hopefully small) followup questions:
Using the macro editor, I was able to access "Set Column Properties" as you suggested. However, my macro does not appear to be writing the desired values to the column properties. Can you look at the macro below and let me know where my syntax is going wrong? I tried to implement the example you gave in http://openmolecules.org/forum/index.php?t=msg&goto=765
<macro name="colPropsTest">
<task name="setColumnProperties">
properties=lookupCount\t1<NL>lookupName0\tWikipedia Entry<NL>lookupURL0\thttp://en.wikipedia.org/wiki/%s
replace=true
column=Compound Name
</task>
</macro>
The "\t" in the code block above represent TAB characters.
Your response to the second question also makes sense. Is there any way to access the current time in milliseconds in DataWarrior macros? For example, if I want to update the filter to only display the last X days of data.
Thank you,
Andrew
[Updated on: Thu, 11 February 2021 19:40] Report message to a moderator
|
|
|
|
|