LAE

Welcome to the LAE community!  Please feel free to start a discussion in the discussion tab or join in a conversation.

Discussions

Members

Resources

Events

 View Only
  • 1.  Counting Specific characters in a field

    Employee
    Posted 02-25-2010 14:21

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: Kelvin

    Hi there
    I am trying to delimit 3 fields each with a delimiter of �. Unfortunately there is a mismatch in the number of delimiters which is causing it to fail. What I need to do is count the number of � in each field and isolate the ones with a mismatch. Is there any way of counting the number of � in each field?

    Below is an example

    Meter POA MeterConfig CurrentTariff

    D�N�N (2) 1�2�3 (2) A�B�C�D (3)
    D (0) 1�2 (1) A�B (1)

    Any help would be awesome


  • 2.  RE: Counting Specific characters in a field

    Employee
    Posted 02-25-2010 14:42

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: stonysmith

    One way of doing this is to remove those characters and then compare the two string lengths.

    fields = strlen(Meter) - strlen(Meter.replace("�",""))

    another way would be to convert the field to an array and then return the length

    Meter_array = Meter.split("�")
    fields = len(Meter_array)


  • 3.  RE: Counting Specific characters in a field

    Employee
    Posted 02-25-2010 14:48

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: MartyWalsh

    Kelvin,
    Another option is to add an extra output pin to the convert delimited node, which will output all records that do not match the header specification.
    eg if you have 3 fields defined in the header, any records that have more fields will be output to the 2nd pin, in a field called "Record", from here you can then use Stony's method of splitting up the string into fields delimited by the character, and using a combination of strcat() and getItem() to create the fields you need.

    Cheers
    Marty


  • 4.  RE: Counting Specific characters in a field

    Employee
    Posted 02-25-2010 15:52

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: Kelvin

    Brilliant - thanks for that