I have a text file from which I need to get the data into datatable to further process the data.
I have used Read Text file activity, saved the data into string then using Generate datatable activity.
Below are the column names
Project definition Description WBS Elem Description Created on Changed on
Please note I have 2 column names same
Screenshot of Generate Datatable activity parameters
So it’s tab delimited. Your Generate Datatable appears to be set correctly. What’s the issue? You won’t see anything in Test Preview unless you paste something into Sample Input. Paste the contents of the text file into Sample Input.
Word says it’s tab. I even read the file into a variable in UiPath and used the ASC function to find out the ASCII code of the delimiter. It comes back as 9 which is, in fact, a tab.
Why the Generate Data Table isn’t working, I have no idea. Won’t work for me either.
Also, even if you get it to work there’s a problem. You have two columns named Description. This will cause an error when trying to generate the datatable.
Another thought, you could use a Replace to replace the tabs with commas or some other delimiter and see if Generate Datatable works with a non-tab delimiter.
Replacing Tab with comma worked and I am able to generate desired datatable. Thank you so much.
Now I have to lookup this datatable and get value for Description column(second one). Is there any way I can have Target Column as Description (skip 1st Description).
You should rename one of those Description columns in the text file, or in the text file variable. Then you can just reference whichever of the columns you want. I’m surprised it will let you create a datatable with two columns named the same.
If you’re really OCD about things like this, like I am then you could replace all the tabs with “,” and then add a " at the beginning and end of each row. Heck, if you do all that you could just write it back to the file, then use Read CSV.
I have somewhat of a similar issue. I have a tab delimited text file and it seems to work except for the header column.
I checked if every entry had a tab. it does. it combines the first 3 into one column, the next 2 into another column, and then 2 have an individual column, and it then creates 3 additional columns named column1, column2, and column 3.
For that you should split on VbTab. Read the file in as simply a text file, split on VbCrLf to get your rows, and split each row on VbTab to get the columns for each row.