Hey guys am trying to automate a process, in which I have to read files from a txt doc and write and store it in a datatable. And there are 7 columns in it and if the txt file does not contain those 3 columns out of 7 we must add the column in the datatable. However am able to add the column names but am getting extra columns “Column1” ,“Column2”, “Column3” . along with the actual column name.
- this is when I manually remove the 3 column names
- expected output
- actual output
Also, please let me know what exactly happened,and why those unwanted columns were added
Welcome back to uipath forum
This will come if there is any blank space instead of text in those txt file
Check once with the input file you receive and try to standardise it
If that cannot be standardised then we can later remove those columns alone with
Remove Datacolumn activity
Yes there is a space after the pipe symbol then the column name and then space and then again pipe symbol. What should i do?
And will there be a same issue when trying to filter values like adding values in status, reason and salary columns
If you cannot configure your txt file, I recommend deleting all added columns. The easy way to do this would be to use the filter activity.If there are certain columns you want, you can keep only them by selecting the keep field as below.
Can you share the screenshot of how you are adding the columns to the data table
Fine there are two ways to handle this either
We need to standardise as said earlier the CSV File and try to avoid blank column or fields
Or if that can’t be done then read the csv and then remove it with expression where it removes blank columns
Refer this for more details
I have a datatable which contains 180 Colums. Out of which some columns are having null values in all the rows. I want to remove those columns.
column1 Column2 Column3 Column4 Column5
001 ABC 5
002 XYZ 6
003 PQR 7
I want to remove Column4 and column5. I am facing this error
Am using add column activity, I want to check if the 3 columns are present if not then am adding 3 add column activities.
Can I give a range of columns to be deleted in column index of Remove datacolumn activity
Remove data column doesn’t take range of columns in it
If you want to remove two data columns then use two remove datacolumn activity with the column names
But we can use DefaultView in that case
Have a view on this thread for more details on datatable functions
Datatable - variable type is the most commonly used variable type by all UiPath users
And it’s been the most often asked queries in forum especially on its manipulation
So I would like to have this post as a repository for those who are looking for expressions related to Datatable
Let’s go one by one keeping dt as name of datatable variable
1. Get number of rows in a datatable dt
dt.Rows.Count (output - int32 type)
2. Get number of columns in a datatable dt
Thanks for help used remove data column activity.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.