I have for each folder loop where trying to add data from csv file into data table finalnaTabela.
After first iteration data is just added to the table without deleting data from previous iteration.
So I tryed to use Clear Data Table activity for all iterations exept the first one, but the error Object reference not set to an instance of an object. appears.
If you want to add datatable schema and data to the datatable at GenerateDataTable activity, it’s unnecessary to initialize or clear the datatable in advance. Probably it works, even if there are no activities before GenerateDataTable activity.
It would be best to verify if the data you are reading contains that many columns.
If you are confident that the columns are fixed, then you can simply reinitialize the DataTable after every iteration using the same snippet which was shared above:
New System.Data.DataTable()
Also, do give read on what @Yoichi -san has detailed above and see if that works out for you.
I tryed, but doesn’t work.
I have several csv files, that I combine into one and convert to string.
Than trying to use Generate Data Table - after first iteration data table is created correctly, but after second GenerateDataTable data is just added to the fullfiled data table from first iteration (it seems that this activity doesn’t create new instance but just add new data to the previous one), and number of columns has growed.
@Olivera_Kalinic During first iteration as like you said it has 19 columns and during second iteration new data got added to the already existing data (which means new data got added to 19 columns)
To avoid this case, clear datatable after every iteration
DataTable property of GenerateDataTable is OutArgument type as the following. This means it creates new instance and not affected by the previous DataTable content.
I think perhaps you need to check input string for GenerateDataTable.