Read CSV file and want to find duplicate value

Hi 

I need advice.

Read CSV file and want to find duplicate value.

if there are duplicate values .I want to display error msg..

I was able to load the CSV and remap it to the map list, but I was unable to check for duplicates values and unable to add error msg.

Image like the attached image

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    Could you elaborate more on what you are trying to do? Are you looking for duplicates on "No" and/or "col1" and/or "col2"? What are you expecting in error1/2/3? What does your current expression rule look like, and what have you tried for finding the duplicate values that is giving you difficulty?

  •  

    At first i want to read csv file and then check csv file data. I'm looking for duplicate value on [No] column.

    if there are duplicate value on [No] column. i want to add error msg and sent it back csv file with error message.

    If there  are no duplicate value register to DB. 

  • 0
    Certified Senior Developer
    in reply to spykid

    Please find the below code. Made a sample code for your understanding. More efficient and simpler code can be created.

    a!localVariables(
      local!doc: ri!doc,
      local!data: readexcelsheetpaging(
        excelDocument: ri!doc,
        sheetNumber: 0,
        pagingInfo: a!pagingInfo(startIndex: 2, batchSize: 5000)
      ).data.values,
      local!formatData: a!forEach(
        items: local!data,
        expression: if(
          a!isNullOrEmpty(fv!item[2]),
          {},
          a!map(
            name: fv!item[2],
            gender: fv!item[3],
            department: fv!item[4],
            tech: fv!item[5]
      )
      )
      ),
      local!duplicateCheck: a!forEach(
        items: local!formatData,
        expression: a!update(
          data: fv!item,
          index: "error",
          value: if(
            length(
              wherecontains(
                fv!item.name,
                local!formatData.name
              )
            )>1,
            "Duplicate Values Found",
            ""
          )
        )
      ),
      local!duplicateCheck
    )

Reply
  • 0
    Certified Senior Developer
    in reply to spykid

    Please find the below code. Made a sample code for your understanding. More efficient and simpler code can be created.

    a!localVariables(
      local!doc: ri!doc,
      local!data: readexcelsheetpaging(
        excelDocument: ri!doc,
        sheetNumber: 0,
        pagingInfo: a!pagingInfo(startIndex: 2, batchSize: 5000)
      ).data.values,
      local!formatData: a!forEach(
        items: local!data,
        expression: if(
          a!isNullOrEmpty(fv!item[2]),
          {},
          a!map(
            name: fv!item[2],
            gender: fv!item[3],
            department: fv!item[4],
            tech: fv!item[5]
      )
      )
      ),
      local!duplicateCheck: a!forEach(
        items: local!formatData,
        expression: a!update(
          data: fv!item,
          index: "error",
          value: if(
            length(
              wherecontains(
                fv!item.name,
                local!formatData.name
              )
            )>1,
            "Duplicate Values Found",
            ""
          )
        )
      ),
      local!duplicateCheck
    )

Children