I am performing some ui automation in a csv file by opening the same in Excel Application Scope. Basically its Ctrl+F and replacing the same with a different value. But while saving the same the format is getting changed and all the columns are coming into a single column.
This workflow is being called from another workflow. If I am running this workflow independently its saving properly and not giving issue.
Have you tried reading the CSV into a datatable, and then doing the data update there, and writing it back to the CSV file?
This is a long shot, but did the originally invoked workflow involve a variable that determined the number of columns of the output data table? If so, that value might not be properly changing.
Another potential cause could be that sometimes opening the file using an Excel Application Scope causes formatting problems. Have you tried performing the same action using a Workbook activity instead of an Excel Application Scope?
May I know the activities that were used
Ok, so actually i have a csv file where there are two columns with the same column name “Source [list]”. I need to apply filter and remove some others columns. So what i am supposed to do is Read CSV → Filter Data table → Write CSV.
If i start doing this with the raw file then it will error out as data table won’t take two columns with same column name. So before Read CSV i have to open the csv file through Excel Application scope and do select whole header row → Ctrl+F ->Type Source [list] → Find Next ->Type Source [list]1 → Click Replace → Save workbook.
Then Read CSV-> Apply Filter → Write CSV.
Then again open the same file using Excel Application scope. Do the above stuffs again and rename back the Source [list]1 to Source [list] and Save workbook. So here its changing the file format and bringing all the columns to a single column.
While reading the data from csv we can disable includecolumnname property
So that it will create a datatable with default columnname
Then later we can change the column name like this with a assign activity
Datatable.Columns(“Columnname”).ColumnName = “new name”
If i disable include column name property then how would i put filter in the data table to remove extra columns.
We can use column index or the default column names that we get like column1, Column2,…
Sorry @Palaniyappan I didn’t get.
If that property is disabled then we will be getting default column names
We can do we that while filtering