Jump to content

Basic Formatting Tips for Workbench Formulas Pushed from Data Lab

John Cox

Recommended Posts

  • Seeq Team

When pushing Formulas to Workbench from Data Lab, you can use "\" and "\n" in a few different ways in the Data Lab code, to create a nicely formatted, multi-line Formula in Workbench:

  • For the Formula pushed to Workbench, a \n can be used for a line return. This is valuable for creating multi-line Formulas with intermediate variable assignments, or for making lengthy, single lines of code more readable. 
  • For the Formula pushed to Workbench, a \ can be used just before a single quote, when you need to include a single quote in the Formula. This helps for example when working with string signals.
  • On the Data Lab side, using a \ at the end of the line continues the code to the next line, helping with readability in Data Lab. 

These are illustrated in the Data Lab code below which pushes a condition Formula to Workbench:



Editing the Formula in Workbench, the Formula appears as we desired:

Formatted Formula pushed from SDL.jpg

Edited by John Cox
remove file upload
Link to comment
Share on other sites

  • Seeq Team

As a much easier alternative to having to manage string delimiters, apostrophe escape characters, line continuation characters, etc. with the approach above, Python offers a multiline string literal feature (3 double or single quotes). We use this approach below (note the 3 double quotes on code lines 6 and 14). We also use the textwrap.dedent() function (link) to nicely indent our code without indenting the final result in Workbench. This alternate approach is much easier to code as well as being more readable on the Data Lab side.  


Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...