See duplications in datarow

Hello,

I have a table in excel that I need to read and extract the headers. I have a problem: sometimes, I have columns that have the same name. So, my idea is:
1 - read first row;
2 - see if I have duplicated strings (comparing the lenght with the different strings);
3 - if yes, add a digit in the end of each string, overwrite in the excel and the read the table.

However, I don’t know how to change the type of variables: from the first step, I will have a inumerable, and I want to change it to array of strings.

I know that I could read the table without the headers option (and the duplication aren’t a problem anymore), but I need to have that option on for other parts of my flow.

Can you help me, please?

When you read the header row, you can convert the rows to elements of a List by iterating over row.Table.Columns. For each column Col, add the column to the list with row(Col).

Now you can use this list to check for duplicates and perform your renaming options.

You can simply put a ToArray() after the output variable of the read row and you will get the array, but will be as object, to read the values you can then use .ToString in each item.

This happens:

I’ll try this! I’ll let you know if it worked.

Thanks

To bcorrea’s point, I think directly converting to an array is a better option (forgot that there was a way to do this in one line).

If your data row is MyRow, assign the array (e.g. MyArray) to MyRow.ItemArray.

You need a variable Object() and not String()

1 Like

It doesn’t recognize “itemarray”…

But if I maintain in Object() I won’t be able to count how many strings it has, or duplications, or write the digits if I have duplications… right?

ItemArray belongs to DataRow objects. I assume nova is not a DataRow.

i dont see why not… objects are like generic types, they will actually be string anyway…
but you can convert to string array like this if preferred:
stringArray = linha.[Select](Function(x) x.ToString()).ToArray()

If I put DataRow, the same error appears

Can you share the workflow (with proprietary information replaced with dummy data if needed)?

Example.xlsx (9.7 KB) Flowchart.xaml (14.1 KB)

I think this sums up… Thank you for your help :slight_smile:

This worked!! Thanks :smiley: :smiley: :smiley:

1 Like

1.) Set list to be an array of Objects.
2.) counter = list.Length (check spelling)

I’ve attached the updated workflow with these changes.

Flowchart.xaml (14,0 Ko)

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.