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.  get Total Record Count

    Employee
    Posted 03-30-2017 10:09

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

    Originally posted by: jpstory

    Hi All

    I have been trying to figure out how to get the total column and record count.

    I managed to get the total column count with:
    self.inputs[0].metadata.__len__()

    Is there a similar way that can tell me the total record count ?


  • 2.  RE: get Total Record Count

    Employee
    Posted 03-30-2017 10:25

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

    Originally posted by: jmok

    Hi jpstory,

    To get a total record count, you can use the groupCount() function within an Agg-Ex node. Please copy and paste the below onto your Lavastorm canvas:

    node:Static_Data
    bretype:core::Static Data
    editor:sortkey=58dd3e8201e84088
    output:@40fe6c55598828e5/=
    editor:XY=570,390
    end:Static_Data

    node:Total_Record_Count
    bretype:core::Agg Ex
    editor:Label=Total Record Count
    editor:sortkey=58dd3e8425a0421a
    input:@4b4668c040aa5a85/=Static_Data.40fe6c55598828e5
    output:@4b4668e708143fb4/=
    prop:GroupBy=<<EOX
    1
    EOX
    prop:Script=<<EOX
    _RecordCount = groupCount()

    emit referencedFields(1,{{^GroupBy^}}), _RecordCount
    where lastInGroup

    EOX
    editor:XY=690,390
    node:Bypass
    bretype:::Bypass
    editor:shadow=4b467f7e02db3a85
    input:@4b467f7e129d45c1/=
    input:@4b467f830ffe047b/=
    output:@40fd2c7436717256/=
    end:Bypass

    node:Sort
    bretype:::Sort
    editor:shadow=4b467f8972dc33df
    input:@40fd2c743ebf4304/=
    output:@40fd2c746a2a3b47/=
    end:Sort

    node:Agg
    bretype:::Agg
    editor:shadow=4b467f9b3d5028c0
    input:@40fd2c7427456e5b/=
    output:@40fd2c744c862db0/=
    end:Agg

    end:Total_Record_Count


    I've created a variable called "_RecordCount" to hold the total record count and i've put a "1" in the GroupBy parameter to group all the records together.

    If you have any questions, please let me know. Thanks, Janice.


  • 3.  RE: get Total Record Count

    Employee
    Posted 03-30-2017 10:38

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

    Originally posted by: jpstory

    Hi jmok

    thanks for looking at this, apolgoies for not making the quesiton clear.

    What I meant to ask is, within Python node, how can I get the total record count of data from a particualr input pin(preferably without looping through all the records).

    which member of self.inputs[0] would return the total record count, thanks!


  • 4.  RE: get Total Record Count

    Employee
    Posted 03-30-2017 10:53

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

    Originally posted by: stonysmith

    There's no such feature. You can't access the record count from within python, without reading all the records and counting them yourself.


    I suppose there is one "jumping thru hoops" method. That would be .. find the name of the input file (probably only accessable thru poking around in the temp directory) and then open that file with the standard python fp=open(filename,"r")

    But it'd be ugly.


  • 5.  RE: get Total Record Count

    Employee
    Posted 03-30-2017 11:47

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

    Originally posted by: jpstory

    thought so..... been looking through each object and correspoding members inside out couldn't find it....

    Thanks!