0

Asset hierarchy definition help

I have a dataset populated by a CSV collector and I am trying to create a virtual view to put the tags into an asset hierarchy. The tag names are of the form

CsvTag.<site>.<equipment><measure>

where

  • <site> is a 4-digit number
  • <equipment> is a 2 digit number
  • <measure> is a 2 digit number

I want a hierarchy that looks like this:

  • My company
    • Site-0001
      • Equipment-01
        • Measure-01
        • Measure-02
        • ...
      • Equipment-02
        • ...
    • Site-0002
      • ... 

but I don't really understand how the regex's need to be constructed

Can anyone help?

5 replies

null
    • alistair_frith
    • 4 wk ago
    • Reported - view

    Is there a good tutorial on the regular expressions needed for creating virtual views? I'm not found much in the Canary resources but it could be that I'm not looking in the right place.

      • smason
      • 4 wk ago
      • Reported - view

      The only thing we have as far as a tutorial goes is from our Project Boot Camp (https://helpcenter.canarylabs.com/t/m1hk30p/views). Because a customer's tag structure could vary, it's hard to create something that is cookie cutter. If the link doesn't provide any help, you can send me an HDB file from your DataSet and I could attempt to create the structure you are seeking.

      • damon_vinciguerra.1
      • 4 wk ago
      • Reported - view

      I've found regexr.com and ChatGPT to be invaluable. I give ChatGPT some examples, tell it what part of the string I'm interested in, and it usually gets me close.

      So an example tag for you would be CsvTag.0000.00.00?

      If so, then ^CsvTag\.\d\d\d\d\.\d\d.\d\d$ would describe every string. You could do something like

      ^CsvTag\.(\d\d\d\d)\.(\d\d)\.(\d\d)$ --> My company.Site-$1.Equipment-$2.Measure-$3

      That might not be exact, but hopefully it's int he ballpark.

      • alistair_frith
      • 4 wk ago
      • Reported - view

       Thanks, yes that's all that I've found. However it did help me cobble together this:

      Which seems to do the job and is reasonably straightforward (I am reminded of a certain quote concerning RegEx's). It might be helpful if that table could show the comments field on the same line instead of only showing it under the selected item.

      • alistair_frith
      • 3 wk ago
      • Reported - view

       Yep, that's pretty close to my format. I also adjusted the tag names coming in (since it's a demo system using randomly generated data and I have full control over the naming), which helped a lot. I now have rules that give me the hierarchy I am after.

      I've been using Copilot quite a lot lately, but not so far for the regex, I'll try it for those.. Thanks also for the pointer to regexr.com though, that does look useful.

Content aside

print this pagePrint this page
  • Status Answered
  • 3 wk agoLast active
  • 5Replies
  • 24Views
  • 3 Following