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.  Need help to sum-up a values in a column.

    Employee
    Posted 10-06-2016 08:57

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

    Originally posted by: Jagdev

    Hi All,

    I am trying to calculate a column value in certain pattern. There is a column with certain value in it and I need to calculate the sum of it.

    Value - 42�58'36.92"
    Calculation - 42+58/60+(36.92/3600)
    Output - 42.97692222

    Regards,
    Jagdev


  • 2.  RE: Need help to sum-up a values in a column.

    Employee
    Posted 10-06-2016 09:13

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

    Originally posted by: Jagdev

    Hi, I achieved this with below code. Is there any other way.

    Sample = 'Lon'.split("�").getItem(0)
    Sample1 = 'Lon'.split("�").getItem(1)
    Sample2 = Sample1.split("'").getItem(0)
    Sample3 = Sample1.split("'").getItem(1)
    Sample4 = left(Sample3,5)
    Sample5 = Sample.int() + Sample2.int()/60 + Sample4.double()/3600
    emit *
    override emit Sample5 as Sample


  • 3.  RE: Need help to sum-up a values in a column.

    Employee
    Posted 10-06-2016 09:14

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

    Originally posted by: AdamParker

    If your code works, why would you want another way?

    Using splits and lists is pretty much how I would accomplish it.


  • 4.  RE: Need help to sum-up a values in a column.

    Employee
    Posted 10-06-2016 09:54

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

    Originally posted by: Jagdev

    Hi Adam,

    I just want to know is there any way I can remove (42�58'36.92") " from entire column.

    Regards,
    Jagdev


  • 5.  RE: Need help to sum-up a values in a column.

    Employee
    Posted 10-06-2016 10:53

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

    Originally posted by: AdamParker

    What do you mean remove it from the entire column?

    Do you want to remove it from the output of the filter that does the calculation?

    Add this after the emit * ...
    exclude 'Lon'


  • 6.  RE: Need help to sum-up a values in a column.

    Employee
    Posted 10-07-2016 01:39

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

    Originally posted by: Jagdev

    Hi Adam,

    I want to remove special character (") from the column.

    Regards,
    Jagdev


  • 7.  RE: Need help to sum-up a values in a column.

    Employee
    Posted 10-07-2016 02:54

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

    Originally posted by: awilliams1024

    Hi Jagdev,

    As the double quote character is used as the delimiter for the string arguments in the replace() function it must be escaped using the backslash character.
    The following will remove the double quote characters from the 'Lon' field:

    tmp_ = Lon.replace("\"","")
    override emit tmp_ as "Lon"

    Regards,
    Adrian