Creating Dictionary From DataTable Incorrectly

I am trying to add all the rows of a DataTable to a dictionary using a basic for each. It is working correctly except for the first row of the DataTable. The first row will not add to the dictionary for some reason.

However, if i delete the current first row and the second row becomes the first row, it adds to the dictionary just fine. Any ideas? Thanks

@jpreziuso We might need to Check your Workflow as to what Steps are you Performing :sweat_smile:

Hey @jpreziuso, If you have DataTable then I would recommend to use “For Each Row” activity instead of basic “For Each”. It will reduce chance of error.
However, if you want to use “For Each” activity then please check your logic where you are increment counter.


1 Like

Sorry, I am using for each row. Here you can see I output the data table and it appears in there. But after running this for each row loop, all the rows are added to the dictionary except for the first row

@jpreziuso Can you show us the Datatable in the Message Box ? and Point which row is not assigned to Dictionary?

1 Like


Please can you check if the first row is taken as a header? For example: If the Read Range activity is used and the Add Headers option is selected.

If this is not the case kindly post a screenshot of the workflow.

1 Like

I do not have a screenshot at this time and can not replicate one. I am using a Read CSV activity that creates the datatable. I do have “Inlcude Column Names” checked but that doesn’t seem to be affecting it.

It looks like this:
Column 1 Column 2
my key that won’t add my value that won’t add

1 Like

@jpreziuso, It looks like your CSV don’t have header. So while using “Read Range” activity please untick “Has Headers” property and it should work fine. (As suggested by @SowmyaLeo)

1 Like

Thanks, I will attempt this. Just seems weird because when I delete the first row and make the second row the first row, it adds to the dictionary fine. If that makes sense

@jpreziuso, It all depends on how you store data in your DataTable. To me your workflow looks good. “For Each Row” activity will iterate through all rows available starting from first row. That’s the reason @supermanPunch was asking for string representation of your DataTable.

1 Like