Results 1 to 5 of 5

Thread: Merging Duplicate rows in a Sheet

  1. #1

    Post Merging Duplicate rows in a Sheet

    Hi Experts,

    Please let me know if it is possible to merge duplicate rows into single row in a data file.

    Regards,
    Jagdev

  2. #2
    Lavastorm Employee stonysmith's Avatar
    Join Date
    Nov 2006
    Location
    Grapevine Tx
    Posts
    770

    Default

    There are basically two methods you can use.. one is to use AGG, but a slightly simpler version is to use Sort-Unique

    There is a shortcut you can use to simplify the need to list ALL columns. It's used in this example:
    Code:
    node:Sort
    bretype:core::Sort
    editor:sortkey=5a720a5a138f6fef
    input:@40fd2c743ebf4304/=Static_Data.40fe6c55598828e5
    output:@40fd2c746a2a3b47/=
    prop:CompareOrderExpr=<<EOX
    map(&field, inputFields())
    EOX
    prop:Unique=true
    editor:XY=810,480
    end:Sort

  3. #3

    Default

    Hi Stony,

    This looks good. I have bit different requirement i.e. Say the primary column where I need to check the duplicate is column name “Name” as per the inline sample. If it finds the duplicate in a column then the merging should happens the way it is mentioned in the output section.

    Name Place Price
    Ram Mumbai 50
    Ram Pune 60
    Shyam Mumbai 70
    Sam Delhi 100

    Output
    Name Place Price
    Ram Mumbai/Pune 110
    Shyam Mumbai 70
    Sam Delhi 100

    Please let me know if you need further clarification.

    Regards,
    Jagdev

  4. #4
    Lavastorm Employee stonysmith's Avatar
    Join Date
    Nov 2006
    Location
    Grapevine Tx
    Posts
    770

    Default

    Code:
    node:Agg_Ex_3
    bretype:core::Agg Ex
    editor:sortkey=5a74a16064b23701
    input:@4b4668c040aa5a85/=Static_Data.40fe6c55598828e5
    output:@4b4668e708143fb4/=
    prop:GroupBy=<<EOX
    'Name'
    EOX
    prop:Script=<<EOX
    t=groupSum(Price)
    p=groupString(Place,"/")
    emit referencedFields(1,{{^GroupBy^}})
    where lastInGroup
    emit p as Place
    emit t as Price
    EOX
    prop:SortInput=true
    editor:XY=970,490
    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:Agg_Ex_3
    
    node:Static_Data
    bretype:core::Static Data
    editor:sortkey=5a74a15010766718
    output:@40fe6c55598828e5/=
    prop:StaticData=<<EOX
    Name,Place,Price:long
    Ram,Mumbai,50
    Ram,Pune,60
    Shyam,Mumbai,70
    Sam,Delhi,100
    EOX
    editor:XY=880,490
    end:Static_Data

  5. #5

    Default

    Hi Stony,

    This is what I was trying to achieve!

    Regards,
    Jagdev

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •